AssureX is recognised as a Silver Sitecore Partner Find out more         
Commerce Development Quick Tips Sitecore

Sitecore Commerce Pipeline and Blocks

It is often said, Sitecore Commerce (XC) an extensible platform. The extensibility offered by the platform is due to the plugin-based architecture it provides.

What is a plugin? Simply put all commerce features are delivered using plugins. A plugin is

  1. Primary means to customise and extend Commerce functionality
  2. Built on the principle of compositional extensibility and opt-in complexity
  3. Importantly, plugins allow you to create a robust solution which is upgradeable, flexible, reusable with a clear separation on concerns.
  4. When adding a new feature or modifying an existing feature do not change any OOTB plugins instead create your own plugin or inject new blocks into existing plugins.

What goes inside a plugin

Among a lot of things which a plugin uses, a plugin consists of pipelines and blocks. The Sitecore Commerce Core uses a pipeline-based framework based on.NET Core Dependency Injection, enabling extensibility and offering flexibility.

These pipelines –

  1. Acts as a container for business logic, like what we have in XP.
  2. Have blocks implementing the business logic akin to processors in XP.
  3. Or blocks can call other pipelines and blocks – Think about the separation of concerns, also be mindful that OOTB these plugins refer to other plugins all the time

And the good news is there are no XML files to juggle with, use Configure.Sitecore class to register pipeline and blocks.

How to view the running pipelines

You can view the running pipeline via the following two ways–

  1. GetRegisteredPipeline postman call -> Under Ops collection

2. Environment Nodeconfiguration log

Pipeline Tracing

The pipeline framework offers the tracing capabilities. This is helpful in monitoring and troubleshooting pipelines. It can be enabled in commerce configs at –
C:\inetpub\wwwroot\<CommerceShops_Sc9>\wwwroot\config.json

Change LogLevel ->Default to Debug and PipelineTraceLoggingEnabled to True

Managing pipelines/Blocks

The project template provided as the part of the SDK includes a ConfigureSitecore class inheriting the interface IConfigureSitecore. In this class in ConfigureServices function, you can define your custom pipelines.

You use addpipeline method to add new pipelines

Once you have configured a new pipeline or want to amend a pipeline, you can –

  1. Add a new block into a new pipeline
  2. You can add a block before/after an existing block
  3. You can replace a block from an existing pipeline – overriding OOTB functionality
  4. Or you can remove a block from a pipeline

I hope this blog provides a high-level understanding of the XC’s pipeline model. Please let me know in the comments.

Did you find this useful? If so, please share with your connections.

Leave a Reply