Monday, 15 February 2016

Commerce Server : How to add a Property to a Profile Definition

Leave a Comment
In this blog post I am going to explain how to add a new Property to a Profile Definition in Sitecore Commerce Server. For example, I’ll show how to add a new property ExternalId to User object into Profile Definition of Sitecore Commerce Server.

Add new column in SQL Server table
  1. Make the following changes in UserObject table of profile database in SQL server:
    Add column: u_external_id NVARCHAR(256) NOT NULL
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'userobject' AND COLUMN_NAME = 'u_external_id')
BEGIN
 ALTER TABLE dbo.UserObject ADD u_external_id nvarchar(256) NOT NULL
END
GO
Create new Data member in Commerce Server Manager
  1. Open Commerce Server Manager. Expand Commerce Server Manager -> Global Resources -> Profiles -> Profile Catalog -> Data Sources -> ProfileService_SQLSource -> Data Objects. Right click the data object you want to add a data member to, and then click New Data Member. I am going to add new data member to User object.
  2. In the New Data Member dialog box, complete below fields:
    Field NameDetails
    Member NameSelect an available data member name from the list. Data members which have already been added to a data object will be unavailable for selection and appear dimmed. The member name must match the name of the column to which the data member maps in SQL server table. The member name can contain a maximum of 127 alphanumeric characters and the underscore (_) symbol. The member name cannot contain spaces.
    Display NameType a display name that contains a maximum of 127 Unicode characters.
    DescriptionType a description for the data member. The description can contain a maximum of 127 Unicode characters.
    TypeSelect the appropriate data type for the data member. The data type must be the same as the property that you will map with the data member.
    Multi-valuedSelect this option to enable the collection of multiple values that are associated with the data member.
    RequiredSpecifies that this property is required on your Web site. However, the Profiles Schema Manager does not enforce this attribute.
    IndexedSelect this option if you want the data indexed on this data member.
    Primary keySelect this option to designate this data member as the primary key. You must select one data member in each data object to be the primary key.
  3. Click Add. The data member appears in the data member list in the New Data Member dialog box.
  4. Click Finished.
Map the data member to a property in profile object.
  1. Open Commerce Server Manager. Expand Commerce Server Manager -> Global Resources -> Profiles -> Profile Catalog -> Profile Definitions. Left click the profile definition object where you want to add a new property. I’ve selected User object profile definition.
  2. Select appropriate information group and then click on Add to add new property.
  3. The property will be appeared in general information group with a new name called New Property 1.
  4. Select New Property 1. You can see a property editor in the right hand section.
  5. Fill the fields in Attributes section. 
  6. Fill the fields in Advanced attributes section. Click on Map to data to map the newly created data member to new property.
  7. Fill the fields in Custom attributes section as per requirement.
  8. Click on apply to save the changes of new property. Now the new property is added to User object.
Comments and suggestions are most welcome. Happy coding!

0 comments :

Post a Comment