Sitecore Commerce - Extend Create User Pipeline

on 01. December 2021. in category Sitecore

Sitecore 9.2 comes with an out of the box pipeline to create users. We wanted to extend that pipeline by sending one more parameter for the purpose of receiving a newsletter and to save that info on customers. The web pipeline is invoked:

to send additional data to pipeline:

In properties we can send dictionary key-value pairs, and the value is an object. We needed to send one parameter that is boolean, but it is possible to send multiple parameters or objects.

Web pipeline has different processors, like create user in Commerce, create user in Sitecore, goals etc. We wanted to extend the creation of users in Commerce. So we had to override Sitecore.Commerce.Engine.Connect.Pipelines.Customers.CreateUser in Sitecore.Commerce.Engine.Connect.dll

Extend Customer Config Changes

We created our CustomCreateUser processor that is a modification of Sitecore.Commerce.Engine.Connect.Pipelines.Customers.CreateUser code. New code is marked with comments as follows:

This processor is patched in Project/NameOfAProject/code/App_Config/Include/Y.Commerce.Engine.Conectors.Customers.config:

The processor calls commerce block DoActionAddCustomerBlock so we had to override that block to extract data we are sending. ConfigureSitecore.cs:

DoActionAddCustomerBlock is modified to CustomDoActionAddCustomerBlock by saving data in component and placing component in commerce context:

Component that is storing data:

CustomDoActionAddCustomerBlock invokes ICreateCustomerPipeline, and in that pipeline we are storing information on a customer by adding AddJoinNewsletterBlock. ConfigureSitecore.cs:

AddJoinNewsletterBlock.cs:

This has been implemented and tested on Sitecore Experience Commerce 9.2

Thank You for Reading
Share this page