Custom Commerce Connect Cart and Orders Entities

Current version: 8.2

If you extend any of the Commerce Server or Commerce Connect types, you should create your own equivalent pipeline processor.

Any entity that is synced into xDB (EAPs or Page Events) needs to be registered in the MongoDbObjectMapper. Inside the Initialize pipeline there is a processor called RegisterDataModelExtensions that registers all of the Commerce Server extension to Commerce Connect types.

If you extend any of the Commerce Server or Commerce Connect types you should create your own equivalent pipeline processor and insert it after RegisterDataModelExtensions, do not replace the RegisterDataModelExtensions pipeline.

The following is an example of a pipeline processor that registers a custom type:

RequestResponse

namespace MyNamespace.Pipelines
{    
    using Sitecore.Analytics.Data.DataAccess.MongoDb;
    using Sitecore.Commerce.Connect.CommerceServer.Inventory.Models;
    using Sitecore.Commerce.Connect.CommerceServer.Orders.Models;
    using Sitecore.Pipelines;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    /// <summary>
    /// Pipeline processor that registers data  model extensions with the BSON class map.
    /// </summary>
    public class MyDataModelExtensions
    {
        ///  <summary>
        /// Processes the pipeline arguments. 
       ///  </summary> 
       ///
      <param name="args">The pipeline  arguments.</param>
      public virtual void Process(PipelineArgs  args)
      {           
      MongoDbObjectMapper.Instance.RegisterModelExtension<MyCustomType>();       
      }
   }
}

Do you have some feedback for us?

If you have suggestions for improving this article,