Jaa


What Are the Virtual Catalog Concepts?

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

Virtual catalogs let you aggregate content from one or more base catalogs. You can define inclusion and exclusion rules, define pricing rules, and change the categorization of the items in the virtual catalog. Virtual catalogs let you override the list price, display name, and rank properties of the base catalog. You can also override all custom properties.

You can create a virtual catalog from another virtual catalog. The catalog that is created is a virtual catalog. However, it can be created from only one source catalog, and that source must be a virtual catalog.

Before you can use virtual catalogs, you should understand the following concepts.

Categories

Categories let you categorize products in a virtual catalog. You can create categories in virtual catalogs just as you do in base catalogs. For more information about how to create categories, see Managing Base Catalogs by Using the Catalog API.

Inclusion and Exclusion Rules

Inclusion and exclusion rules define how you include items from one or more base catalogs, or one virtual catalog. You can include or exclude an entire catalog, a category and all its descendants, or individual products and variants. When you define an inclusion rule on an item, all descendants of that item are included in the virtual catalog. For example, if you have a base catalog "Books" and you include the category "Fiction" in your virtual catalog, all items in that category are included in the virtual catalog.

To exclude items from the virtual catalog, you use an exclusion rule. For example, if you have a base catalog "Books" and you want to include all categories except "Autobiographies", you would first include the entire catalog, and then define an exclusion rule for "Autobiographies".

When you define an exclusion rule on an item, all descendants of that item are excluded from the virtual catalog. Exclusion rules take precedence over inclusion rules. For example, suppose you have a book that is a member of two categories, "Fiction" and "Historical Novels". If you have a rule that includes "Fiction" and another rule that excludes "Historical Novels", your book will not be included in the virtual catalog.

Pricing Rules

Pricing rules let you specify prices in the virtual catalog. For example, if you have a base catalog "Books" and you want to create a catalog for preferred customers and offer a 10% discount, you would create a virtual catalog and define a price rule for the catalog.

A catalog-level price rule is always applied to all the catalog items included from the base catalog. However, if additional category-level, product-level, or variant-level price rules are also specified, these prices rules will override the catalog-level price rule. If a product has a single parent category, the price rule on that category affects the price of the product. If a product has multiple parent categories with one assigned as the primary parent category, only the rule on the primary parent category affects the price of the product. If an item has multiple parent categories and no primary parent, catalog-level rules apply.

Parent-Child Associations

When you add items from a base catalog to a virtual catalog, the items in the virtual catalog will inherit the parent-child associations from the base catalog. You cannot delete these relationships in the virtual catalog. However, you can define new relationships in the virtual catalog.

Relationships

When you add items from a base catalog to a virtual catalog, the items in the virtual catalog will inherit the relationships from the base catalog. You cannot delete these relationships in the virtual catalog. However, you can define new relationships in the virtual catalog.

Rebuilding Virtual Catalogs

Because a virtual catalog contains items from one or more base catalogs, it is possible that changes that you made to a base catalog will affect the contents of a virtual catalog. Therefore, you should rebuild your virtual catalogs after you make any changes to the schema or base catalog data. For example, suppose you have a virtual catalog of books with a category "Autobiographies". If you add a book to the "Autobiographies" category in the original base catalog, this addition will not be immediately reflected in the virtual catalog. You must rebuild the virtual catalog for the changes to appear.

Do not rebuild catalogs simultaneously. If you have more than one catalog to rebuild, wait until the rebuild of one is complete before starting another. Otherwise, a deadlock can occur.

Importing and Exporting

You can import virtual catalogs from XML files. To do this, you follow the same steps as importing a base catalog. For more information about importing catalogs, see Importing Catalog Data by Using the Catalog API.

You can export virtual catalogs to an XML file. When you export a virtual catalog, you must specify if you want to export it as a virtual catalog. You do this by using the ExportAsVirtualCatalog property of the CatalogExportOptions object. If you export it as a virtual catalog, Commerce Server exports the rules associated with the virtual catalog to the XML file. It also exports overridden properties and custom categorization created in the virtual catalog. For more information about exporting catalogs, see Exporting Catalog Data by Using the Catalog API.

Materialized Virtual Catalogs

A materialized catalog is a snapshot of a catalog. When you materialize a virtual catalog, the virtual catalog data is stored in tables. This improves the run-time performance of the virtual catalog. It has the performance of a base catalog for all search and browse operations.

During a production deployment, you would typically import virtual catalogs as materialized when you will not be editing the catalogs directly. The Commerce Server incremental materialization handles the updates to the catalogs. To perform incremental materialization, use the MaterializeVirtualCatalogs property on the CatalogImportOptions object.

You should not edit materialized catalogs. If you must edit a materialized catalog, un-materialize it and then edit it as a virtual catalog.

To materialize or un-materialize a catalog, use the CatalogFlags property of the Information property on the ProductCatalog object.

Name Mangling

Virtual catalogs can contain products, product variants, and categories from multiple base catalogs. Because product IDs and category names are not unique across base catalogs, a virtual catalog might have two similarly named categories. To avoid ambiguity when you access these items, you must refer to a product in a virtual catalog as ProductId(BaseCatalogName). You must refer to a category in a virtual catalog as CategoryName(BaseCatalogName). If you create a new category in a virtual catalog, you must refer to it as CategoryName(VirtualCatalogName).

The category names and product IDs returned by the Catalog System in recordsets and datasets are in this format. For example, the ProductCollection member of the CatalogItemsDataSet object returned by the ChildProducts property of the Category type contains names in this format for the child products in the category.

The following example illustrates the difference between accessing products and categories in a base catalog and accessing products and categories in a virtual catalog.

public static void AccessExample(CatalogContext context)
{
    // Access products and categories in a base catalog.
    ProductCatalog baseCatalog = context.GetCatalog("BaseCatalogName");
    Category baseCatalogCategory = baseCatalog.GetCategory("CategoryName");
    Product baseCatalogProduct = baseCatalog.GetProduct("ProductId");

    // Access products and categories in a virtual catalog.
    ProductCatalog virtualCatalog = context.GetCatalog("VirtualCatalogName");

    // To access a category in a virtual catalog, the category name should  
    // be in the format CategoryName(BaseCatalogName).
    string categoryName = string.Format("{0}({1})", "CategoryName", "BaseCatalogName");
    Category virtualCatalogCategory = virtualCatalog.GetCategory(categoryName);

    // To access a product in a virtual catalog, the product ID should be in
    // the format ProductId(BaseCatalogName).
    string productId = string.Format("{0}({1})", "ProductId", "BaseCatalogName");
    Product virtualCatalogProduct = virtualCatalog.GetProduct(productId);
}

See Also

Reference

VirtualCatalog

Other Resources

Managing Virtual Catalogs by Using the Catalog API