Extending Sitecore Experience Commerce

When developing features and/or customizations for Sitecore Experience Commerce 9 (XC) it is good that you make sure you know the overall architecture of the product and its connection to Sitecore Experience Platform (XP).
In this post I want to discuss some of the basic must know architectural aspects as I also showed in my Sitecore Symposium 2019 session.

As you might know there is a connection between XC and XP. On one side you have the Item Service API from Sitecore XP, which is used by XC to get Sitecore Items and storefront configuration settings.
Next to that Sitecore XP (or the Commerce Engine Connect module) gets data and performs commerce actions using the OData APIs from XC using the ServiceProxy, like adding products to a cart and creating the order.

XC Platform architecture

Both of these endpoints and integrations can be extended to create custom functionalities. The XP Item Service for example we extended for uploading media items in the product import process, which I described earlier in another post.

The XC Engine itself has some ‘building blocks’ which we can use to our advantage.

XC building blocks

  • Entities; every data object(like Cart or SellableItem) inside XC is an Entity. You can create your own types and extend the existing ones.
  • Components; every (custom) field on an Entity is added as an Component. You can create your own Component types and add them to any Entity.
  • Pipelines; just like in XP, XC uses the pipeline pattern which makes it easy for us to extend and overwrite OOTB functionalities.
  • Policies; these look a lot like Components but are used as settings.
  • Commands; commands are used as Unit of Work functionalities and mostly triggered from an OData API.
  • Minions; just like the Agents in XP, XC has its own variant called Minions. These Minions run every X minutes, can watch a list and be scaled out.

Last but not least, there is the configuration. Currently you have to configure storefront settings partially in XP and partially in XC, which makes it sometimes hard for you to alter some settings without having to do a code change and deploy.

XC configuration

What we did in some of our custom(ized) functionalities is move all configuration to the XP side. You can extend the storefront templates with extra fields and read those out when XC gets that specific Sitecore Item using the Item Service.
For example, you can extend the GetShopPipeline to store extra fields from the Storefront template.

All other examples I showed during the session can be found on GitHub, so go check that out: https://github.com/GuidovTricht
A couple of these repositories are also described in my other blog posts.