Partager via


How to Delete Categories

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

You can delete categories from a base catalog or a virtual catalog by using the DeleteCategory method of the ProductCatalog object. This method deletes the category from the catalog but does not delete any child categories or products under it.

This method does not delete the category from the catalog database. You must use the PurgeDeletedItems method to remove the category from the catalog database.

To delete a category from a catalog

  1. Get the catalog that contains the category to be deleted.

  2. Delete the category by using the DeleteCategory method.

Example

This example demonstrates how to delete a category from a base catalog. The base catalog "Books" has a category "Autobiography."

public static void DeleteCategory(CatalogContext context)
{
    // Get the "Books" catalog.
    ProductCatalog catalog = context.GetCatalog("Books");

    // Delete the category "Autobiography."
    Catalog.DeleteCategory("Autobiography");
}

See Also

Other Resources

Managing Base Catalogs by Using the Catalog API