Many times, developer’s wants to set some quantity in their inventory in order to test inventory functionality in starter site. I created a script which will help developers to populate inventory. Kindly follow the steps below
- Make sure you set Inventory Catalog and product catalog details
- There are two sql queries mentioned below one for deleting existing inventory and another for inserting new inventory for all products
- So first execute delete query and then insert query
Delete from [StarterSite_productcatalog].[dbo].[Default_InventorySkus]
GO
DECLARE @InventoryCatalogName VARCHAR(50)
DECLARE @ProductCatalogName VARCHAR(50)
SET @InventoryCatalogName = ‘Default’
SET @ProductCatalogName = ‘Adventure Works Catalog’
INSERT INTO [StarterSite_productcatalog].[dbo].[Default_InventorySkus]
([SkuOid]
,[InventoryCatalogName]
,[ProductCatalogName]
,[SkuId]
,[SkuVariantId]
,[Backorderable]
,[Preorderable]
,[Status]
,[OnHandQuantity]
,[StockOutThreshold])
SELECT newid(),
@InventoryCatalogName,
@ProductCatalogName,
productid,
variantid,
0,
0,
1,
999,
1
from [Adventure Works Catalog_CatalogProducts]
Where (productid !=” and variantid !=”) or (productid !=” and variantid =”)
If you like this post, please click on our sponsor advertisement.
