Partager via


CreateInventoryCatalog Method (String)

Creates an InventoryCatalog in the inventory system.

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

Syntax

'Declaration
Public Function CreateInventoryCatalog ( _
    catalogName As String _
) As InventoryCatalog
'Usage
Dim instance As InventoryContext
Dim catalogName As String
Dim returnValue As InventoryCatalog

returnValue = instance.CreateInventoryCatalog(catalogName)
public InventoryCatalog CreateInventoryCatalog(
    string catalogName
)
public:
InventoryCatalog^ CreateInventoryCatalog(
    String^ catalogName
)
public function CreateInventoryCatalog(
    catalogName : String
) : InventoryCatalog

Parameters

  • catalogName
    Type: System..::.String
    The name of the inventory catalog. May not be nullNothingnullptra null reference (Nothing in Visual Basic).

Return Value

Type: Microsoft.CommerceServer.Inventory..::.InventoryCatalog
An instance of the InventoryCatalog object.

Remarks

An inventory catalog is used to store inventory information for the products and variants in the catalog system. One inventory catalog can contain inventory information for one or more product catalogs (base catalogs and virtual catalogs) but one product catalog can be associated with one inventory catalog only. The inventory catalogs can also store inventory information for products which do not belong to product catalogs in the catalog system. By default the inventory system will provide an inventory catalog named Default. The Default inventory catalog cannot be deleted. If successful this method will return an instance of the InventoryCatalog object. You can the use the InventoryCatalog object to create, edit, retrieve and delete inventory information for the SKUs in the inventory catalog.

The catalogName should:

  • Not be nullNothingnullptra null reference (Nothing in Visual Basic) or blank.

  • Not exceed 85 characters.

  • Not contain the .,"[]'()# characters.

Examples

This example demonstrates how to create an inventory catalog and access its properties.

public InventoryCatalog CreateInventoryCatalog()
{
  InventoryCatalog inventoryCatalog = null;
  try
  {
    inventoryCatalog = inventoryContext.CreateInventoryCatalog("name of the inventory catalog", "description of the inventory catalog");
    // Different ways of accessing the name and description of the inventoryCatalog
    Console.WriteLine(inventoryCatalog.Name);
    Console.WriteLine(inventoryCatalog.Description);
    Console.WriteLine(inventoryCatalog[InventoryCatalogsDataSetSchema.InventoryCatalogName]);
    Console.WriteLine(inventoryCatalog[InventoryCatalogsDataSetSchema.InventoryCatalogDescription]);
    Console.WriteLine(inventoryCatalog.Information.InventoryCatalogs[0].InventoryCatalogName);
    Console.WriteLine(inventoryCatalog.Information.InventoryCatalogs[0].InventoryCatalogDescription);
    // To access custom properties on the inventory catalog use the
    // indexer. Assuming VendorId is a custom property added to the
    // inventory catalog, the value of the VendorId property can be
    // accessed as follows:
    Console.WriteLine(inventoryCatalog["VendorId"]);
    Console.WriteLine(inventoryCatalog.Information.InventoryCatalogs[0]["VendorId"]);
  }
  catch(ValidationException ex)
  {
    Console.WriteLine(ex.Message);
   }
  catch (CatalogDatabaseException ex)
  {
    Console.WriteLine(ex.Message);
  }
  catch (EntityDoesNotExistException ex)
  {
    // ex.EntityId will contain the name of the inventory catalog
    Console.WriteLine(ex.Message);
  }
  return inventoryCatalog;
}

Permissions

See Also

Reference

InventoryContext Class

InventoryContext Members

CreateInventoryCatalog Overload

Microsoft.CommerceServer.Inventory Namespace