다음을 통해 공유


InventorySku Class

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

This class provides functionality to manage properties of an inventory SKU.

Namespace:  Microsoft.CommerceServer.Inventory
Assembly:  Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)

Syntax

'Declaration
Public Class InventorySku _
    Inherits CatalogObjectBase
'Usage
Dim instance As InventorySku
public class InventorySku : CatalogObjectBase
public ref class InventorySku : public CatalogObjectBase
public class InventorySku extends CatalogObjectBase

Remarks

Implements functionality of the InventoryCatalog class. The attributes will contain information about the inventory catalog. The class contains methods to get and update product information.

Examples

public bool CreateAndDeleteInventorySkus()
{
  bool result = true;
  InventoryCatalog inventoryCatalog = null;
  InventorySku inventorySku = null;
  string inventoryCatalogName = "Default";
  string productCatalogName = "Dummy Product Catalog";
  string prefix = "Test";

  InventoryContext inventoryContext = helper.InventoryContext;
  #region Setup
  /** Note: Adding the association with a product catalog is necessary before creating inventory skus 
   * for products and variants in that product catalog.
   **/
  try
  {
    //Get The Default Inventory Catalog
    inventoryCatalog = inventoryContext.GetInventoryCatalog(inventoryCatalogName);
    //Add Product Catalog association to this inventory catalog
    inventoryCatalog.AddProductCatalog(productCatalogName);
    inventoryCatalog.Save();
  }
  catch (Exception e)
  {
    Console.WriteLine("Unexpected Exception trying to create a sku " + e.Message);
    throw e;
  }
  #endregion

  try
  {
    //Creating an inventory sku for a product
    inventorySku = inventoryCatalog.CreateSku(productCatalogName,prefix+" PID", 100, StockStatus.Enabled);

    //Get the inventory sku
    inventorySku = inventoryCatalog.GetSku(productCatalogName, prefix + " PID");

    //Update the inventory sku
    inventorySku.Backorderable = true;
    inventorySku.BackorderLimit = 5;
    //Saving the changes
    inventorySku.Save();
    //Delete inventory Sku
    inventoryCatalog.DeleteSku(productCatalogName, prefix + " PID");
    //Remove mapping
    inventoryCatalog.RemoveProductCatalog(productCatalogName);
    inventoryCatalog.Save();
  }
  catch (Exception e)
  {
    Console.WriteLine("Unexpected exception when manipulating inventory skus" + e.Message);
    result = false;
  }
  return result;
}

Inheritance Hierarchy

System..::.Object
  Microsoft.CommerceServer.Catalog..::.CatalogObjectBase
    Microsoft.CommerceServer.Inventory..::.InventorySku

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

InventorySku Members

Microsoft.CommerceServer.Inventory Namespace