All about the Sitecore Commerce Profile System
Wednesday, May 10, 2017
Layer One - Technical Lead
The Sitecore Commerce profile system is one of the remaining legacy Commerce Server sub-systems, and like the other Sitecore Commerce systems is incredibly flexible but somewhat complicated. This post will give you the run down on the what, how and why so you can familiarize yourself with designing or developing against the system.
There are three components that make up the Commerce Server Profile system:
- Profile database and tables
- Data Objects and Members
- Profile Definitions
They are all installed with the default Sitecore Commerce installation. Data is stored in the SQL tables, mapped in the data objects/members and accessed and displayed through the profile definition. Each database table has a data object, each database column has a data member. For each database table and table object you’ll have a matching profile definition and within the profile definition you can create groups to organize your properties, which are mapped to a data member and therefore to a column in your database table.
Creating distinct profile definitions allows for the support of one-to-many and many-to-many relationships within the profile system. Multi-valued profile fields can be created by selecting the multi-value checkbox when creating a data member or profile property and this allows you to support scenarios such as a user having multiple addresses. To reference another profile, you can select the Profile type from the type field on the profile property and your profile definition as the Type Reference. If you’re using a version of Sitecore Commerce older than 8.2.1 this will also affect how the property is displayed in the Customer and Order manager and setting the Type and Type Reference fields will work for both multi-value and single value properties.
With the basic Sitecore Commerce installation, User Object is the only profile definition implemented. This table holds the basic user information, first name, last name, phone numbers etc. and includes fields like those in a membership provider including password information and several date fields, which don’t serve much of a purpose when the user information is also stored in the Sitecore User tables and integration with the ASP.NET membership provider. As with other commerce components, a pipeline model that is used to create users and the Commerce Connect pipelines are implemented to add a user to the Sitecore, then create a User Object profile when a new user is created.
Commerce Connect introduces the concept of Commerce Users and Commerce Customers. Commerce Users define someone that logs into the ecommerce website, Commerce Customers are the entity the user makes a purchase on behalf of. In a B2C site, these are one and the same and thus for each Commerce User, a Commerce Customer is created each in their respective domain (CommerceUser and CommerceCustomer). Confusingly in Commerce Connect it is Customers, not Users that have addresses (even though they are stored in the same place in Commerce Server). The Sitecore Reference Storefront provides an example of how to use a multi-valued value by implementing the Party pipelines for Commerce Customers to add, edit and remove addresses for your profiles.
The pipeline model of the Commerce Connect framework provides a way to extend the capabilities beyond simply storing and retrieving information from the Commerce Server profile system. Data can be stored in external systems, information can be modified or you can use additional profile definitions to support extended user modelling scenario for a B2B solution.
In future releases the profile system is set for a massive overhaul which will see Commerce Server profiles replaced with a new framework and as such the best approach is to program against the Commerce Connect framework and keep code that directly accesses Commerce Server isolated from the rest of your ecommerce solution. Whilst it does have its pitfalls (like the complex configuration) the Commerce Server Profile System in incredibly flexible and when combined with the Commerce Connect framework allow you to model your user store in a way that works best for your organization and implementation.