Jaa


How to Create a SKU

This topic describes how to create a SKU in an inventory catalog.

To create a SKU

  1. Get the inventory catalog to which you are adding the SKU by using the GetInventoryCatalog method of the InventoryContext object. You can also add a SKU when you create a new inventory catalog. For information about how to create a new inventory catalog, see How to Create an Inventory Catalog.

  2. Create the SKU by using one of the CreateSku methods of the InventoryCatalog object.

  3. Add properties to the SKU object.

  4. Save the SKU.

Example

This example adds a SKU with the productId "5514LM" to the inventory catalog. Before the SKU can be created the product catalog "AdventureWorksSummerCatalog" must be mapped to the inventory catalog. For more information about how to do this see How to Create an Inventory Catalog.

The example sets the properties to allow for backordering and sets the StockOutThreshold property of the InventorySku object to 1. The parameter for the method is an InventoryContext object.

public static void CreateSKU(InventoryContext inventoryContext)
{
    // Get the existing inventory catalog "SummerClothing".
    InventoryCatalog inventoryCatalog = inventoryContext.GetInventoryCatalog("SummerClothing");

    // Create a SKU in the inventory catalog. Add 10 products with productID "5514LM".
    // Set the stock status to enabled.
    InventorySku sku = inventoryCatalog.CreateSku("AdventureWorksSummerCatalog", "5514LM", 10, StockStatus.Enabled);
           
    // This item can be backordered.
    sku.Backorderable = true;
            
    // Set the StockOutThreshold. There must be at least this amount in inventory for the item.
    // to be considered in stock.
    sku.StockOutThreshold = 1;
    sku.Save();
}

See Also

Other Resources

Concepts of the Catalog System

How to Create an InventoryContext Object