How to Create a Static Catalog Set
A catalog set consists of one or more catalogs that you make available to different users or organizations. You create a static catalog set by specifying the catalogs you want to include in the catalog set. You can edit the set of catalogs at any time.
To create a static catalog set
Use the CatalogSetsContext property on the CatalogContext object to create a CatalogSetsContext object.
Use the CreateStaticCatalogSet method on the CatalogSetsContext object to create a StaticCatalogSet object.
Use the AddProductCatalog method on the StaticCatalogSet object to add product catalogs to the catalog set.
- or -
Use the CreateStaticCatalogSet method on the CatalogSetsContext object to create a StaticCatalogSet object with the catalogs specified by the productCatalogs parameter.
Use the Save method on the CatalogSet object to save the catalog set to the system.
To add a catalog to a static catalog set
Use the AddProductCatalog method on the StaticCatalogSet object to add product catalogs to the catalog set.
Use the Save method on the CatalogSet object to save the changes.
To remove a catalog from a static catalog set
Use the RemoveProductCatalog method on the StaticCatalogSet object to remove product catalogs from the catalog set.
Use the Save method on the CatalogSet object to save the changes.
To delete a static catalog set
- Use one of the DeleteCatalogSet methods on the CatalogSetsContext object to delete the specified catalog set.
Example
The following example creates a static catalog set that contains two product catalogs, Catalog1 and Catalog2, which exist in the system. It then removes Catalog1 from the catalog set and adds Catalog3.
public static void CreateStaticCatalogSet(CatalogContext context)
{
// Get the CatalogSetsContext object.
CatalogSetsContext catalogSetsContext = context.CatalogSetsContext;
// Create the catalog set.
string setName = "PreferredCustomerCatalog";
string description = "Catalog for preferred customers";
StaticCatalogSet staticCatalogSet = catalogSetsContext.CreateStaticCatalogSet(setName, description);
// Add the product catalogs to the catalog set.
staticCatalogSet.AddProductCatalog("Catalog1");
staticCatalogSet.AddProductCatalog("Catalog2");
// Save the changes.
staticCatalogSet.Save();
// Edit the catalog set.
// Remove Catalog1 and add Catalog3.
staticCatalogSet.RemoveProductCatalog("Catalog1");
staticCatalogSet.AddProductCatalog("Catalog3");
// Save the changes.
staticCatalogSet.Save();
}