Adding additional profile properties to users in Sitecore Commerce/Commerce Server

The profile system in Commerce server is driven by the database definition. Because of this, there are three steps to adding a new field to the profile definitions.

Add a field to the relevant database table

When you look at the profile definition in the Commerce Server Management tool, you'll notice that there are a few objects that make up profile. This allows for a higher level of flexibility and the ability to define relationships between users and addresses, organisations and users etc. The below screenshot shows the individual profile definitions, along side the profile database and tables and you can see that each profile definitions has a matching table in the database.

When you add a field it's best to always make the field Nullable this is because the Sitecore Commerce Connect framework will create the entity with the ID (and sometimes External ID) and then update the record with the additional profile fields.

In this example I'm adding a basic string (nvarchar) field u_new_field.

Update the Data Object to Include the New Field

The relationship between the database table and field and the profile object is handled in the Data Sources area in the Commerce Server Manager. To add a new field, you are adding a new Data Member to the object.

When adding a new member, you can select the database field from the Member Name select list. You can only select fields that aren't already mapped to a data member.

Click Add and Finished and you're done in this section

Update the Profile Definition to include the new Data Member

As a last step you now have to add the field/data member/property to the profile definition. Navigate to the definition that matches the table you added your field to. Each definition has a number of groups, these groups prefix the properties where your are accessing or setting them. For example, the First Name property can be accessed as GeneralInfo.first_name. Make sure you use the name field, rather than the display name of the property

Once you've decided on the appropriate section for your field, you can section the section and click the Add button at the bottom of the window. Select Add a New Property.

Fill out the Name (What you will use to access the field) and Display Name (How the field will be labelled in the Commerce Server Manager and Customer and Orders desktop tool (depending on your version). To map the property to your Data Member/Field you need to compete the Map to Data field by selecting the appropriate data source and member.

Click Okay and Apply. You need to save the Profile Definition as well, but it will trigger an alert to do this when you move away from the current Profile Definition screen.

If you've found all the screenshots difficult to follow, I've also recorded all the steps in a screencast.