How to extend Registration Model in storefront


I need to add few custom fields ex:ReceiveEmailAlert to Registration Form in storefront (Which I was able to do by extending commerce registration view). But How Can i pass these custom field information to the 'AccountManager.RegisterUser() method, since it currently accepts only few fields or How can I save custom fields info to DB where on registration user details are stored?

Below is my custom class 

public class Registration : RegistrationUserRenderingModel
public bool ReceiveEmailAlert { get; set; } = true;
public bool ReceiveMobileAlert { get; set; } = false;

Able to capture the user inputs for ReceiveEmailAlert in the controller post method. I am struck on how to pass these info while registering to db.

  • A lot of changes required to achieve this, You have to customize SXA components, commerce engine connect layer and commerce engine with a custom plugin.

    Do following changes in SXA components.

    1. Create custom AccountManager class, inherit it from existing AccountManager and add your custom RegisterUser method with parameters you need.

    2. Your custom method code will be same as existing RegisterUser method except while creating the CreateUserRequest object add the custom data (e.g. ReceiveEmailAlert) to Properties collection of CreateUserRequest instance.

    3. In Sitecore Service collection (in configuration) replace the existing AccountManager registration with your custom account manager implementation.

    4. Create custom AccountController, inherit from existing AccountController.

    5. Add your custom Registration methods in the controller. Use existing registration methods code and change the method name.

    6. In Post method implementation, type cast the account manager to your custom account manager type and call your custom RegisterUser method.

    7. In Sitecore Service collection (in configuration) replace the existing AccountController registration with your custom account controller implementation.

    8. Duplicate the existing Registration rendering in Sitecore and change the controller name to your custom account controller, also change the method name to your custom registration method.

    9. Copy the existing registration view and create the custom view, do the changes in the custom view as per above controller and method changes.

    10. Replace the existing registration rendering with custom registration rendering in your registration page presentation.


    Do following changes in Commerce Engine Connect layer.

    1. Create a pipeline processor for "commerce.customers.createUser" pipeline.

    2. Use existing code from "Sitecore.Commerce.Engine.Connect.Pipelines.Customers.CreateUser, Sitecore.Commerce.Engine.Connect".

    3. Using "args.Request" get your custom data from properties collection.

    4. Assume that you have properties in your entityView.Properties collection with name "ReceiveEmailAlert" and "ReceiveMobileAlert", get those properties and set the values, follow the code for setting the email property. (you have to add these properties by custom plugin in commerce engine)

    5. Replace the existing CreatUser pipeline processor with your custom CreateUser pipeline processor implementation.


    Create a custom plugin that will enhance the functionality of existing "Sitecore.Commerce.Plugin.Customers" plugin in commerce engine.

    Following blocks should be replaced with your custom implementation:

    1. GetCustomerDetailsViewBlock - This will be called from CreateUser pipeline processor. You have to write code to add your custom properties in EntityView for "AddCustomer" and "EditCustomer" actions.

    2. TranslateEntityViewToCustomerBlock - This will be called by CreateUser pipeline processor to save customer details, You need to write code to get custom property values from EntityView and fill in the customer entity, (You can store your custom values in a separate component class and add it to components list of customer entity.)

    3. UpdateCustomerDetailsBlock - This block is to update the existing customer details.

    4. Custom plugin should replace following blocks in commerce engine:

    4.1 Replace existing "GetCustomerDetailsViewBlock" in the "IGetEntityViewPipeline" with your custom "GetCustomerDetailsViewBlock".

    4.2 Replace existing "TranslateEntityViewToCustomerBlock" in the "ITranslateEntityViewToCustomerPipeline" with your custom "TranslateEntityViewToCustomerBlock".

    4.3 Replace existing "UpdateCustomerDetailsBlock" in the "IUpdateCustomerDetailsPipeline" with your custom "UpdateCustomerDetailsBlock".


    Hope this will help.

  • Hi jyoti,

    When using your own models (or extending existing models), make sure you patch the necessary config files so your class is used instead of the OOTB Sitecore class (ex. <commerce.xa><models><RegistrationUserRenderingModel type="[class name including namespace, assembly name]" /> </models></commerce.xa>). You may have to delete the existing entry first and then add your custom entry. I highly advise extending the existing models to minimize the risk of breaking the existing CXA components.

    Also, as a quick note, you will need to modify/extend existing models/pipeline blocks in order to pass and store this information in the Commerce Engine. This will involve:

    • Extending the model passed from the Razor View
    • Extending the model passed to the pipeline that's responsible for communicating with the Commerce Engine.
    • Extending the model received from an authenticated call. Usually, this will be the same model passed from the front end, but potentially could be different
    • Creating new pipeline blocks/components as necessary to extend existing pipelines/entities to store the alert. If this alert needs to be modified by business users, create a view to display/edit this field in Business Tools

    Hope this helps!

  • In reply to Vipin Banka:

    Thanks Vipin. I am also facing this issue.

    I am new in Sitecore commerce so, it would be great help if you can point any article where example code is mentioned. It would be easier for me to do the same implementation.
  • In reply to Jitendra Kumar:

    Here are some links those explains the concepts with different examples but helpful to get familiar:

    For exact implementation use Resharper or similar tool to understand the exiting code.
  • After few days of research, I found that xConnect Custom Facet can be also use to store custom Customer information which are not part of Sitecore Commerce 9 Customer. Below link can help you creating xConnect Custom Facets:

  • In reply to Jitendra Kumar:

    I don't think this applies in the described case, as the extended customer information needs to be accessible from the Commerce Engine which by default does not have access to Xdb (and it should not really).
  • In reply to Vipin Banka:

    Hi Vipin,

    Thanks for detailed information on the implementation part. I will try implementing as suggested by you and also taking account Rejaie Johnson point to add patch config for custom model.
  • In reply to Jyoti Bagali:

    I am still struck on this. Vipin! answer suggested by you will require lots of work and time which we don`t have now. Can this be resolved easily with 'Entity Composer' feature with XC upgrade 9.0.2? I have not upgraded yet..hence asking if anyone has see such possibility?

  • In reply to Jyoti Bagali:

    All the Entity Composer is going to do for you is extend the Customer entity in the Commerce DB, and create views for accessing them in BizFx. That's it. About 80% of what Vipin described would still apply in 9.0.2.
  • In reply to Jyoti Bagali:

    Here you can see how to use Entity Composer. Its a very good article.