How to Update an Inventory Catalog
For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.
After you create an inventory catalog you may want to change the information in the catalog. You can update the specified properties of all SKUs in the inventory system, or just the SKUs that match a specified expression.
To update specific properties for all SKUs in an inventory catalog
Create an UpdateClause object that contains the names of the properties to update and their new value.
Use the UpdateSkus method of the InventoryCatalog object to update the specified properties of all SKUs in the catalog.
To update specific properties for specific SKUs in an inventory catalog
Create an UpdateClause object that contains the names of the properties to update and their new value.
Use the UpdateSkus method of the InventoryCatalog object to update the properties of the specified SKUs.
Example
This example describes how to update inventory SKUs. It first updates the Memo property of all SKUs to "Temp". It then updates the SKUs that match an expression. It creates two update clauses and applies these updates to all SKUs with OnHandQuantity equal to 10.
public static void UpdateSKUs(InventoryContext inventoryContext, string inventoryCatalogName)
{
// Get the inventory catalog.
InventoryCatalog inventoryCatalog = inventoryContext.GetInventoryCatalog(inventoryCatalogName);
// Update the Memo to Temp for all SKUs.
UpdateClause[] updateClause = {new UpdateClause (InventorySkusDataSetSchema.Memo, "Temp")};;
catalog.UpdateSkus(updateClause);
// Update specific SKUs based on an expression.
// Create the expressions for columns to be updated.
// The first expression adds 10 to the OnHandQuantity.
// The second epression updates the "Memo" column to "Temp1".
UpdateClause[] updateclauses = { new UpdateClause(InventorySkusDataSetSchema.OnHandQuantity, "OnHandQuantity+10",true),
new UpdateClause(InventorySkusDataSetSchema.Memo, "Temp1")};
// Apply the update clauses to the inventory SKUs with
// OnHandQuantity equal to 10.
catalog.UpdateSkus(updateclauses, "OnHandQuantity=10");
}