Deleting product type
To delete a product type, you must perform the following:
- Get an instance of the following managers:
Get the specified product type.
- Catalog manager
- Catalog definition manager
Get an instance of the product type to be deleted. For more information, read Querying product types.
Check if there are products associated with the product type.
If there are products associated with the product type, you must first delete them. For more information, see Products.
Remove the UI definition for the product type.
To remove the product type from the catalog definition, call the RemoveProductTypeDefinition method of the catalog definition manager and pass the product type as an argument.
Mark the product type for deletion.
To mark the product type to be deleted, call the DeleteProduct method of the catalog manager and pass the ID of the product as an argument.
Save the changes.
To delete the product type, save the changes to the catalog manager.
Adjust the catalog definition for a single product type.
If after deleting the product type, there is only one type left, you must adjust the catalog definition for a single product type. To do this, call the AdjustForSingleProductType method of the catalog definition manager and pass the remaining product type as an argument.
TIP: To delete multiple product types, query them and execute the code below for each one of them.
NOTE: If the product type has products associated with it, you must first delete the products.
Here is a code example:
CatalogManager catalogManager = CatalogManager.GetManager();
CatalogDefinitionManager catalogDefinitionManager =
ProductType productType = catalogManager.GetProductType(productTypeId);
(catalogManager.GetProductTypes().Count() == 1)