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:
-
Create an
EcsInventoryProductclass that derives fromInventoryProductentity that contains the information required to identify stock information in your ECS. -
Create an
EcsCommerceContextclass that derives from theCommerceContextBaseclass 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. -
Create an
EcsInventoryProductBuilderclass that derives from theInventoryProductBuilder, and override all methods of the base class to properly handle yourEcsInventoryProduct. In particular, you must use the newEcsCommerceContextinsideCreateInventoryProduct() to populate the additional properties of yourEcsInventoryProduct. For example:RequestResponsevar ecsProductInfo = ((EcsCommerceContext)this.CommerceContext).EcsProductInfo; -
Create an
EcsInventoryAutomationProviderclass that derives fromInventoryAutomationProvider, and override theGetProductNotifications,GetExpiredNotifications, andGetProductsBackInStockmethods. These methods must return anEcsInventoryProductfor theStockNotificationRequest.Productproperty. Automation state data in the inventory system is stored as JSON serialized strings, so this will usually require some custom deserialization code. -
Register your
EcsInventoryProductentity atsitecore/commerce.Entities/InventoryProduct. -
Register your
EcsCommmerceContextatsitecore/commerceContext. -
Register your
EcsInventoryProductBuilderatsitecore/inventoryProductBuilder. -
Register your
EcsInventoryAutomationProvideratsitecore/inventoryAutomationProvider.