3

I have to add some new property on the commerce customer's profile of a commerce 8.2.1 solution. I don't have any particular external integration needs. All the user's data can be stored in sitecore/sitecore commerce, the only needs I have is to keep the editing support of the user manager.

Before posting I followed this guide from version 8.1: http://commercesdn.sitecore.net/SCpbCS81/SitecoreCommerceConnectGuide/en-us/#Concepts/c_ProfileStoreFundamentals.html

Hovewer I found some issues:

  1. If I set a datatype other than string in the web.config, I get an exception at runtime
  2. If I set the datatype as string, linked to an item via droplink (so It would be stored as a string Guid), I can edit the field from sitecore and it stores the field successfully, but when I try to set the same field via code, the field is left blank
  3. If the field is a datatype string type, but a simple single line instead of a link to an item, I'm able to save the data into it the same way I do (that not work), for the linked field.

To set the custom user field via code I do the following (assume that user is a valid CommerceUser object):

var userProfile = User.FromName(user.UserName, true).Profile;
userProfile.SetCustomProperty(propertyName, propertyValue);
userProfile.Save();

Am I skipping some steps or doing something wrong?

0

1 Answer 1

1

Code that you posted is for setting custom property on default user object in Sitecore not for Sitecore CommerceUser / profile object.

There is not much documentation on how to extend Sitecore CommerceUser in 8.2.1. You need to do it in Commerce Server Manager. You need to extend UserObject under Profile node and also make some SQL changes.

This walk-throughs will help you work with custom profile for Sitecore CommerceUser:

Maybe also take a look here: https://blog.ryanbailey.co.nz/2017/06/sitecore-commerce-server-profile.html

As it was hard to extend default commerce user profile, we have used regular Sitecore users instead. In our project last year, we have basically omitted this special Commerce user profile as it was not clear how it will be used in Sitecore Commerce 9. We planned to do upgrade. We have created regular Sitecore users under custom domain with custom profile template. You can do the same by following this blog post for instance -> https://briancaos.wordpress.com/2014/06/12/sitecore-users-custom-profile-properties/

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.