In this blog post I show one of two ways to extend commerce entities. With the Composer it is possible to extend the commerce entities without coding. I will guide you through the steps from creating the template
to the availability of the values in Sitecore.

Composer

You will find the Composer on the home screen of the business tools. With Sitecore XC 9.1 you can create new templates directly with the composer. In previous version you had to create the template from the view of your desired entity.

With the next steps we will create a template for an entity view.

Open the composer, click on the arrow button and choose “Create Template”.
Enter the details for your template and click on the checkmark button.
Click on the name of the newly created template.

Template details

Now that the template is created, we can define the properties and set constraints.

Click on the arrow button and choose “Add Property”
Enter the details of the property. You can choose from five built-in property types: Boolean, DateTime, Decimal, Integer and String.

I have added three properties:

  • HDR: Boolean
  • Panel Type: String
  • Frame Rate: Integer

As next step I will add constraints to these properties. For the string type I add a “Selection Option Constraint” to limit the possible values to “LCD”, “LED” and “OLED”. The frame rate will be limited to values between 50 and 200 with a “Min-Max Constraint”.

After you have added properties you can add constraints to these. Select “Add Min-Max Constraint” or “Add Selection Option Constraint” to open the dialog.
Add the desired details to your constraints. Caution: You are currently not able to change these values afterwards. If you close this dialog and you want to change the values, you must remove the complete property and create it again.

After you have setup the complete template you can edit the default values by choosing “Edit View” from the arrow button menu.

Edit the input fields and set the desired default values.

Linking a template to extend commerce entities

Without linking the template to a commerce entity, it will not show up anywhere. Therefore, you must define to which entities the template should be linked. You can assign the template by linking the template by Tag, Entity Type or Item Definition. Click on one of the three buttons in the details row.

If you link the template by more than one way, only one of these values must be fulfilled that the view will show up for an entity.

Merchandising

Now after we have linked the template with an entity type, we can have a quick look into the Merchandising views. Open the Merchandising view and select a catalog. Navigate through the category’s and open a sellable item.

As you can see in this screenshot, our template is now available in the sellable item view.

Because the item is already published, we are not able to modify the properties of our custom “Technical Details” view. Therefore, we must add a new entity version. Click on the “Plus” icon in the “Entity Versions” row. Confirm the security question and select the new version with a click on the version “2”.

The “Edit View” command is now available. Click on the command and setup some custom values.

After we have modified the values, we must publish this entity version. Click on the arrow button in the Summary row and select the Command “Promote to next workflow state” and confirm the popup.

Click on “Promote to next workflow state”
Select “Submit” from the Command DropDown. It is only this single command available.

The sellable item version “2” is still not published. It is now ready for review. You need to promote it again to the next workflow step. Repeat the steps from above. This time you have the Command “Approve” or “Reject” available. Select “Approve” and confirm the popup.

Now that we have set up some test data, we will have a look into Sitecore and see if we can find the new properties.

Sitecore Content Editor

Because we have not updated the data templates in Sitecore, the new properties will not show up. You can navigate to the item and have a quick look. On my installation the Sitecore content path is:
/sitecore/content/Sitecore/Storefront/Home/Catalogs/Habitat_Master/Habitat_Master-Departments/Habitat_Master-Televisions/6042260

Select the “COMMERCE” Ribbon and click on “Update Data Templates”

Verify that the template was generated by navigating to
/sitecore/templates/Commerce/Catalog Generated/Components
Note the structure of the generated template: Template -> Base Template -> Property group -> Properties

The generated template for our custom view.

Next step is to assign the template to our “Commerce Product” template. On my machine I had to navigate to: /sitecore/templates/Project/Sitecore/Commerce Product
Select the “Content” tab and add the generated template “Technical Details” to the selected base templates:

Add the generated template to the base templates of the commerce product template.

Because we have added the base template the values should show up in the details of the sellable item. Navigate to the sellable item and scroll down to the properties. If the default values and not the configured values show up. Click on “Refresh Commerce Cache” and select the sellable item again.

Our custom view with the values we have configured in the merchandising tool.

Summary

In this post we extended a sellable item with a custom view. But you can extend a lot of other entity types in the same way: Catalog, Category, Promotion Book, Promotion, PriceBook, PriceCard, Customer and Order.

It is an easy way to extend commerce entities without coding. But there are some points you must keep in mind:

  • You have to create this templates manually on all commerce installations (developer PCs and Servers), or you have to implement a solution to synchronize between the environments.
  • Even you can create the templates without developers, you still will need developers to display the properties.
  • With a code first approach you will have more control about the views. If you later want to move form composer templates to coded views you may run into data migration scenarios.

Leave a comment

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