I am able to add products and associated with Category programmatically. Now I need to add the Inventory sets to its associated products.

Do I need to add the Inventory sets while adding the Sellabale items? Or do I need to create the Inventory sets after Sellable items are created and just associate the Sellable items with Inventory set?

2 Answers 2


You can create the inventory set separately and associate it with the sellable items. These are the steps I follow:

  1. Create an InventorySet and associate the inventory set with the catalog (You can use the IAssociateCatalogToInventorySetPipeline pipeline).
  2. Create an InventoryInformation record. Associate the InventoryInformation record with the InventorySet by creating a "InventorySetToInventoryInformation" relation using the ICreateRelationshipPipeline pipeline.
  3. Retrieve the SellableItem and add an InventoryComponent with an inventoryassociation that points to the InventoryInformation entity:

    InventoryAssociations.Add(new InventoryAssociation { InventoryInformation = new EntityReference(id), InventorySet = new EntityReference(inventorySet.Id) }

  • 1
    any possible to add some sample code here?
    – Hussain
    Aug 17, 2018 at 10:23

There is also a simpler way, just use AssociateSellableItemToInventorySetPipeline, you need to run it and provide:

  • SellableItem ID
  • Variant ID
  • Inventory ID
  • EntityView (contains basic inventory information like Quantity, etc.)


var sellableItemInventorySetArgument = new SellableItemInventorySetArgument(productId, inventoryId);
sellableItemInventorySetArgument.VariationId = variantId;

var entityView = new EntityView();
entityView.Properties = new List<ViewProperty>();
entityView.Properties.Add(new ViewProperty() { Name = "Quantity", Value = "5" });
sellableItemInventorySetArgument.EntityView = entityView;

associateSellableItemToInventorySetPipeline.Run(sellableItemInventorySetArgument, context);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.