Deleting variations

To delete a variation, you must perform the following:

  1. Get an instance of the catalog manager.
    Get an instance of the CatalogManager object.
  2. Get the variation detail for the specified variation.
    To get the variation detail, call the GetProductVariationDetails method of the manager and filter the collection by the ID of the variation. 
  3. Mark the variation detail for deletion.
    To mark the detail to be deleted, call the DeleteProductVariationDetail method of the manager and pass the ID of the detail as an argument.
  4. Mark the variation for deletion.
    To mark the variation to be deleted, call the DeleteProductVariation method of the manager and pass the ID of the variation as an argument.
  5. Save the changes.
    To delete the variation, save the changes to the manager.

TIP: To delete multiple variations, query them and execute the code below for each one of them.

Here is a code example:

public static void DeleteVariation(Guid variationId)
{
    CatalogManager catalogManager = new CatalogManager();
 
    var detail = catalogManager.GetProductVariationDetails().Where(d => d.ProductVariationParent.Id == variationId).SingleOrDefault();
 
    catalogManager.DeleteProductVariationDetail(detail.Id);
    catalogManager.DeleteProductVariation(variationId);
 
    catalogManager.SaveChanges();
}

Next steps

+1-888-365-2779
sales@sitefinity.com

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK