CommerceSitecore

Managing Stock(inventory) in multiple warehouses

OOTB Sitecore Commerce Engine(CE) allows you to have one inventory set for a catalog(products set). There might be situations when multiple warehouses would have the stock for a single product. In such a scenario you can easily extend CE to look for stock in multiple warehouses.

Availability

When a product is added to the cart, the storefront sends a request to CE to find out if the product is available in stock. CE comes with an API api/GetBulkStockInformation which calls a command GetBulkStockInformationCommand. This command runs IGetSellableItemPipeline to get a sellable item with the availability component.

 

InvenoryPipelines

 

OOTB CE has PopulateItemAvailabilityComponentBlock which I replaced with PopulateItemAvailabilityComponentFromMultipleWarehousesBlock. In ConfigureSitecore.cs, I added

 

While the block PopulateItemAvailabilityComponentFromMultipleWarehousesBlock is inheriting from PopulateItemAvailabilityComponentBlock. In spite of only checking the default inventory set, I am iterating over all the inventory sets to get the stock information.

Note: I am calling the inventory sets as warehouses in the code. While passing the names of warehouses in the context(request header) from storefront. This is not in the scope of this post but just to mention, our warehouses are system entities that are managed in XP.

I am sharing some highlights of the code from PopulateItemAvailabilityComponentFromMultipleWarehousesBlock as the actual implementation could differe from one business to other.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *