Update Stock Information

Developer tasks for using service method UpdateStockInformation.

UpdateStockInformation is used to modify a SKU and associated inventory catalog.

At your visual studio solution setup:

  1. Reference the Sitecore.Commerce.Connect.CommerceServer and Sitecore.Commerce.dll.
  2. Pick the class in your solution where want to use this service method.
  3. Paste in the code below to use the service method.
    var provider = new CommerceInventoryServiceProvider();
    var commerceStockInfo = new CommerceStockInformation
                {
                    ProductId = "newSku",
                    VariantId = "newSku1",
                    ProductCatalogName = ProductCatalogName,
                    OnHandQuantity = 15,
                    InventoryStatus = CommerceServer.Core.Catalog.StockStatus.Enabled,
                    StockOutThreshold = 1
                };
    var request = new UpdateStockInformationRequest(string.Empty, commerceStockInfo);
    var result = provider.UpdateStockInformation(request);