Extend the InventoryProduct entity

The InventoryProduct entity is used to uniquely identify a product/stock information in the external commerce system (ECS). If the default InventoryProduct entity is not sufficient to identify stock information, you must extend this entity, as well as a few provider classes in the inventory system.

To extend the InventoryProduct entity:

  1. Create an EcsInventoryProduct class that derives from InventoryProduct entity that contains the information required to identify stock information in your ECS.

  2. Create an EcsCommerceContext class that derives from the CommerceContextBase class that exposes properties that represent the additional information required to identify stock information in your ECS. It will be the responsibility of the client site / application to set these properties based on client state.

  3. Create an EcsInventoryProductBuilder class that derives from the InventoryProductBuilder, and override all methods of the base class to properly handle your EcsInventoryProduct. In particular, you must use the new EcsCommerceContext inside CreateInventoryProduct() to populate the additional properties of your EcsInventoryProduct. For example:

    var ecsProductInfo = ((EcsCommerceContext)this.CommerceContext).EcsProductInfo;
  4. Create an EcsInventoryAutomationProvider class that derives from InventoryAutomationProvider, and override the GetProductNotifications, GetExpiredNotifications, and GetProductsBackInStock methods. These methods must return an EcsInventoryProduct for the StockNotificationRequest.Product property. Automation state data in the inventory system is stored as JSON serialized strings, so this will usually require some custom deserialization code.

  5. Register your EcsInventoryProduct entity at sitecore/commerce.Entities/InventoryProduct.

  6. Register your EcsCommmerceContext at sitecore/commerceContext.

  7. Register your EcsInventoryProductBuilder at sitecore/inventoryProductBuilder.

  8. Register your EcsInventoryAutomationProvider at sitecore/inventoryAutomationProvider.