How to Delete Multiple Items

The Commerce Server Core Systems Catalog System enables you to delete multiple items in a single operation. To do this, use the DeleteItems method on the ProductCatalog object. You must specify a search clause. All items that match the search clause are deleted, and the number of deleted items is returned.

To delete multiple items

  1. Create a search clause to specify the items to be deleted.

  2. Use the DeleteItems method to delete the items in the catalog.

Example

This example describes how to delete multiple items from a catalog. It deletes all items that have a price less than $2.00. It then writes the number of deleted items to the console.

private static void DeleteMultipleItems(ProductCatalog catalog)
{
    // Delete a category from the catalog.
    int deletedItems = Catalog.DeleteItems("cy_list_price<2");

    // Write the number of deleted items to the console.
    Console.WriteLine("Number of deleted items: {0}", deletedItems);

}

See Also

Other Resources

How to Manage Bulk Updates and Deletions

How to Update Multiple Items