• Not Answered

How to add tags programmatically to a customer in Sitecore commerce?

Hi... 

I'm able to add Tags to a customer from Biztool. I can't see any method in Sitecore.Commerce.Services.Customers where I can insert Tags to customer record. 

 

Please let me know if I need to override methods to do it or if there is any easy way to make it work.

Any help will be appreciated.

Thanks.

2 Replies

  • Hi,

    There is no OOTB method that can do it, you need to customise it.

    Start from looking into "RegisterUser" method in "Sitecore.Commerce.XA.Foundation.Connect.Managers.IAccountManager, Sitecore.Commerce.XA.Foundation.Connect".
    This method calls "commerce.customers.createUser" pipeline and this pipeline calls a pipeline processor "Sitecore.Commerce.Engine.Connect.Pipelines.Customers.CreateUser, Sitecore.Commerce.Engine.Connect" that creates a customer in commerce engine.

    the code in the processor
    - gets an entity view for the customer from commerce engine, an entity view contains the property collection which you can set, (this is similar to BizFx where you click Add button for a customer)
    - then it sets the specific property with values received in request, e.g. "DomainName", "LoginName" etc.
    - then it calls a DoAction API operation to save it in commerce engine.

    copy the existing processor code and replace with your copied one and debug it, it will give you good idea.

    you need to send your tags details in the "Tags" property.

    It depends on your specific scenario that how much you need to customise but you can replace AccountManager implementation with yours as well if needed.
  • In reply to Vipin Banka:

    Thanks Vipin. Will give it try.