• Not Answered

Changing User name

Hello everyone,

Is it possible to change the username for commerce user?

5 Replies

  • Yes, is it!

    IVisitorContext service = ServiceLocator.ServiceProvider.GetService<IVisitorContext>();
    ManagerResponse<UpdateUserResult, CommerceUser> managerResponse = AccountManager.UpdateUser(service, profile.FirstName, profile.LastName, profile.PhoneNumber, profile.EmailAddress);
  • In reply to Andrei Paliakou:

    This would update the email address but not the username. OOB username and email are 2 separate fields, but default SXA Registration pushes the email in both fields. The UpdateUser you mentioned here only updates Email. You would need to create an overload for this method to be able to update username.
  • You can also do that in core database, using SQL statements. let me know if you want to go this route. will provide more details
  • In reply to Sachin Magon:

    Thank you Sachin,
    Would you please elaborate a little bit more on this?
  • In reply to Milad Azimi:

    I don't think SQL Statements is a good idea. When you create a user in Sitecore Experience Commerce, it is being created in Sitecore (Core DB), Commerce (Shared DB) and xDB. So Updating it in Core DB using SQL Statements wouldn't work. I'd personally create an overload for AccountManager.UpdateUser to make sure the pipeline is doing everything properly.