1. プロファイル管理

ユーザープロファイルの作成とログイン

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

ユーザー プロファイルを作成し、Sitecore APIからログインします。

Visual Studioソリューションのセットアップで、次の操作を行います。

  1. Sitecore.Commerce.Connect.CommerceServerとSitecore.Commerce.dllを参照します。

  2. ソリューションでユーザーを作成してログインするクラスを選択します。

  3. ユーザープロファイルを作成するには、次のコードをコピーして貼り付けます。

    var customerServiceProvider = new Sitecore.Commerce.Services.Customers.CustomerServiceProvider();
    var userName = @"CommerceUsers\testUser";
    var password = @"mY_P@ssw0rd";
    var email = @"[email protected]";
    var shopName = Sitecore.Context.Site.Name;
     
    // create the user
    var result = customerServiceProvider.CreateUser(new Sitecore.Commerce.Services.Customers.CreateUserRequest(userName, password, email, shopName));
     
    if (result.CommerceUser != null)
    {
        // if the user was created, log in the user
        var isLoggedIn = Sitecore.Security.Authentication.AuthenticationManager.Login(userName, password, false);
  4. ログイン。

この記事を改善するための提案がある場合は、 お知らせください!