How to add a Custom property in Sitecore XC Entity – Part 1

I write this blog with the below version of the Sitecore.

XP9.0.2
XC9.0.3

We know it’s not possible to get all your needs done from out of box features provided by any product, there is always something missing. And fortunately like Sitecore XP, you can also extend the feature of Sitecore XC. In this article, I am going to show you how to have a custom field for the product entity of XC. As it would become too much longer to go I am splitting the complete process into two blogs –

  • First on Dedicated to XC operation
  • Second, showing the Extended filed on the actual website

The process in XC is the same for all the entities but you still have to implement the custom logic if you want for any specific business need.

  1. So let’s begin with log in to Sitecore launch pad and open the commerce Business tool, key in the credential for your XC environment as well.Custom-property-in-Sitecore-XC_1
  2. Now Click on the Merchandising icon.
  3. Select the Catalog for which you want to extend the product property. In my case it is Habitat_Master.
  4. Select a category and Sellable item from it, for the purpose of example, I am just selecting a random product as below –
    Custom-property-in-Sitecore-XC_2
  5. Now click on the Summary block of the sellable item and try to add view. if add view is disabled then you must need to add a new entity version to do this just above the add view click on entity version and add new entity version.
  6. If you have added an entity version make sure that you have selected that new version.
  7. Now you can see add view is enabled to click, then click on that and add a view.
  8. Add property to your newly added view by clicking on options menu add property action. Add Name, Display Name, and Type.
    Custom-property-in-Sitecore-XC_3
  9. There are only five types are available for our property to select one of them.
    • String
    • Integer
    • Boolean
    • Decimal
    • DateTimeOffset
  10. After Adding property to your view you can also add some option constraints for your property, which will helpful for editing the property of your view. To add option constraint click on Add Selection Option Constraint from the options menu for this example I am not using the constraint option.
    Custom-property-in-Sitecore-XC_4
  11. On the edit window, you can add options constraint to your corresponding property. select the property from the drop-down and add options as many you want by click on (+) button.
    Custom-property-in-Sitecore-XC_5
  12. Edit your view, Now add some actual data to your property by click on edit view from the options menu of your view. select your property
  13. To make this property available for all sellable item we must need to create a template of this property and assign to sellable item entity. to do this click on Make Template action from the options menu of your view and add Name and Display Name for the template on the edit window.
    Custom-property-in-Sitecore-XC_6
  14. Now you have created the template of your property successfully, it’s time to assign this template to a sellable entity go-to composer tool from Sitecore Experience Commerce dashboard wherein template section your newly created template will be appearing.
  15. Click on your own template and on your template panel there is a Detail block, on its right side there is an option that you can apply on your template. form this option click on Link to Entity action to assign your template to the sellable entity.
  16. After doing this now all the entities of the sellable items will have our new view and property.

Now let’s see how we can use this added property into the XP side.

10800cookie-checkHow to add a Custom property in Sitecore XC Entity – Part 1

Add a Comment

Your email address will not be published. Required fields are marked *