Using Sitecore Commerce 10.1

The following method updates only the default profile properties(like phone, name).
It is not updating the custom properties. The custom properties are available for the user, when I check in debug.

No errors. The update isn't happening, when I check in biz tools.

public void UpdateProfileProperty(string propertyName, string propertyValue)
    CustomerServiceProvider customerProvider = new CustomerServiceProvider();    
    GetUserRequest userRequest = new GetUserRequest("MyDomain\\myemail.com");
    GetUserResult result = userRequest != null ? customerServiceProvider.GetUser(userRequest) : null;
    CommerceUser user = result.CommerceUser;
    if (commerceUser != null)
       commerceUser.SetPropertyValue(propertyName, propertyValue);
       // Update the user
       var updateRequest = new UpdateUserRequest(commerceUser);


The property updating code which is in Feature.Accounts works fine. But I want it to be common as it has to be used in other Feature projects also. So, I'm trying to have the code in Foundation.Accounts which is a class library project.

This is the code in Feature.Accounts which works.

public class ProfileController : AccountProfileController
        public ProfileController(Sitecore.Commerce.XA.Feature.Account.Repositories.IProfileViewRepository profileViewRepository,
            IProfileEditorRepository profileEditorRepository, IAccountManager accountManager, IStorefrontContext storefrontContext, IContext sitecoreContext,
            Repositories.IProfileViewRepository UserProfileViewRepository, IVisitorContext visitorContext)
            : base(profileViewRepository, profileEditorRepository, accountManager, storefrontContext, sitecoreContext)
            this.ProfileViewRepository = UserProfileViewRepository;
            this.VisitorContext = visitorContext;                

        public Repositories.IProfileViewRepository ProfileViewRepository { get; set; }
        public IVisitorContext VisitorContext { get; }

        public JsonResult UpdateUser(UserOfferDetails inputModel)
            BaseJsonResult baseJsonResult = new BaseJsonResult(base.SitecoreContext, base.StorefrontContext);
            var profile = ProfileViewRepository.GetProfile(VisitorContext.UserName);
                if (profile != null)
                    StringPropertyCollection propertyBag = new StringPropertyCollection
                        { "OfferValue",inputModel.OfferAmount},
                        { "ProspectId",inputModel.ProspectId}

                    baseJsonResult = ProfileEditorRepository.SaveProfile(profile, propertyBag);

                return Json(baseJsonResult, JsonRequestBehavior.AllowGet);
  • How you have added those custom properties to the commerce side? Did you add a new component to customer or extend existing component? Commented Feb 23, 2022 at 14:42
  • Sorry no idea about commerce. But I can see those properties in biz tools. @Gaurav
    – sukesh
    Commented Feb 23, 2022 at 14:44
  • So what is the name of custom property that you are talking about? Commented Feb 23, 2022 at 14:46
  • ProspectId is the name of the custom property
    – sukesh
    Commented Feb 23, 2022 at 14:48
  • As I can understand this is added by someone as custom. You can add one more block in the pipeline that is being used for updateuser in Sitecore commerce side, just add it after the existing block and then in that new block get the properties and set those. For that you need to know in which component did you or your team added those custom properties. Commented Feb 23, 2022 at 14:52


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.