The Catalog system basically has four main objects:
1. The CatalogManager object is the only externally creatable object. The progid is Commerce.CatalogManager. You can use this object to manage all the catalog schema, create/delete catalogs, import from and export to csv and xml files and search the catalog system.
2. The ProductCatalog object is used to manage an individual catalog in the catalog system. An instance of this object can be obtained by calling the CatalogManager.GetCatalog() method. You can then use the productcatalog object to create/edit/delete products and categories in the catalog.
3. The Category object wraps the functionality of a category in a catalog. An instance of the this object can be obtained by calling the ProductCatalog.GetCategory() method. You can use the category object to update the category properties, add/delete relationships to other categories and products, add/delete parent/child categories, add/delete child products and search the category.
4. The Product object wraps the functionality of a product in a catalog. An instance of the this object can be obtained by calling the ProductCatalog.GetProduct() method. You can use the product object to update the product properties, add/delete relationships to other categories and products, add/delete parent categories and add/delete product variants.
A typical sample for accessing these objects would be :
‘ Create the oCatalogManager object
Set oCatalogManager = CreateObject(“Commerce.CatalogManager”)
‘ Initialize the oCatalogManager with the sitename
Call oCatalogManager.Initialize(“siteName”, false)
‘ Initialize the oCatalogManager with the connection string to the catalog database
Call oCatalogManager.Initialize(“connection string”, true)
‘ Get the productcatalog object
Set oProductCatalog = oCatalogManager.GetCatalog(“catalogname”)
‘ Get the category object
Set oCategory= oProductCatalog.GetCategory(“categoryname”)
‘ Get the product object
Set oProduct = oProductCatalog.GetProduct(“productid”)
Some do’s and don’ts when using these objects
1. Avoid initializing the CatalogManager object more than once in your application. The CatalogManager object should be initialized once on startup and reused (can be stored in the application state for web applications). If for some reason you have to initialize the CatalogManager object multiple times prefer to initialize it using the connection string. Initializing the CatalogManager object using the siteName is expensive and resource intensive and doing this repeatedly is going to severly impact the performance of your application.
2. When perfroming searches on a catalog specify appropriate paging parameters. See this article on how you can take advantage of some of the optimizations built in the catalog system when doing searches. The underlying stored procedures are tuned to account for the conditions mentioned in this article.
3. See this article on the correct way to specify input parameters for your search conditions.