Ordering Pipeline Blocks

O

Specifying an order

When calling the ConfigurePipeline method on Framework.Pipelines.SitecorePipelinesConfigBuilder you can specify an integer for the “order” parameter. This value specifies the order in which to run your configuration, not the order of the individual pipeline block. For example, when creating my TaxJar plugin I wanted to replace the out-of-the-box tax calculation block. Unfortunately the block was registered in the SitecoreServicesConfigurationExtensions.cs class in the Sitecore.Engine plugin rather than the actual Tax plugin. Since this will load last, my plugin was never loading into the pipeline. I updated the configuration in plugin’s ConfigureSitecore.cs to remove the existing block, and register my new blocks.

services.Sitecore().Pipelines(config => config
    .ConfigurePipeline<ICalculateCartLinesPipeline>(builder => builder
        .Remove<CalculateCartLinesTaxBlock>()
        .Add<Kjaneb.Commerce.Plugin.Tax.TaxJar.Pipelines.Blocks.CalculateCartLinesTaxBlock>().Before<CalculateCartLinesTotalsBlock>()
    , "main", 5000)
    .ConfigurePipeline<ICalculateCartPipeline>(builder => builder
        .Remove<CalculateCartTaxBlock>()
        .Add<Kjaneb.Commerce.Plugin.Tax.TaxJar.Pipelines.Blocks.CalculateCartTaxBlock>().Before<CalculateCartTotalsBlock>()
    , "main", 5000)
);

By specifying an order greater than the default (1000) I was able to control how the blocks were loaded and override the default tax calculation, even though it wasn’t included in the tax plugin.

About the author

Kelly Brennan

Add comment

By Kelly Brennan

Recent Posts

Recent Comments

Archives

Categories

Meta