GetInventoryCatalogs Method

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

Returns an InventoryCatalogCollection object containing the list of all the inventory catalogs in the inventory system.

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

Syntax

'Declaration
Public Function GetInventoryCatalogs As InventoryCatalogCollection
'Usage
Dim instance As InventoryContext
Dim returnValue As InventoryCatalogCollection

returnValue = instance.GetInventoryCatalogs()
public InventoryCatalogCollection GetInventoryCatalogs()
public:
InventoryCatalogCollection^ GetInventoryCatalogs()
public function GetInventoryCatalogs() : InventoryCatalogCollection

Return Value

Type: Microsoft.CommerceServer.Inventory..::.InventoryCatalogCollection
An InventoryCatalogCollection object containing the list of all the inventory catalogs in the inventory system.

Remarks

You can iterate through the InventoryCatalogCollection and access the properties of the individual inventory catalogs using the InventoryCatalog object.

Examples

This example demonstrates how to get the inventory catalogs and access the properties of the individual inventory catalogs.

public void GetInventoryCatalogs()
{
  try
  {
    InventoryCatalogCollection inventoryCatalogs = inventoryContext.GetInventoryCatalogs();
    int numInventoryCatalogs = inventoryCatalogs.Count;
    foreach(InventoryCatalog inventoryCatalog in inventoryCatalogs)
    {
      Console.WriteLine(inventoryCatalog.Name);
      Console.WriteLine(inventoryCatalog.Description);
      // Accessing associated product catalogs
      foreach(string productCatalog in inventoryCatalog.AssociatedProductCatalogs)
      {
        Console.WriteLine(productCatalog);
      }
    }
    // Accessing the InventoryCatalogs dataset
    foreach(InventoryCatalogsDataSet.InventoryCatalog inventoryCatalog in inventoryCatalogs.DataSet.InventoryCatalogs)
    {
      Console.WriteLine(inventoryCatalog.InventoryCatalogName);
      Console.WriteLine(inventoryCatalog.InventoryCatalogDescription); InventoryCatalog inventoryCatalogObject = inventoryContext.GetInventoryCatalog(inventoryCatalog.InventoryCatalogName);
      // Accessing associated product catalogs
      foreach (string productCatalog in inventoryCatalogObject.AssociatedProductCatalogs)
      {
        Console.WriteLine(productCatalog);
      }
    }
  }
   catch (CatalogDatabaseException ex)
  {
    Console.WriteLine(ex.Message);
  }
}

Permissions

See Also

Reference

InventoryContext Class

InventoryContext Members

GetInventoryCatalogs Overload

Microsoft.CommerceServer.Inventory Namespace