0

How can I delete a programmatically created configurable product with it's associate products?

  • I have tried retrieving the simple products from the configurable product and delete each simple product and then delete the configurable product.. it's a bit of a code, so thought there might be another way I can achieve this simpler – Mag-Newbie May 7 '15 at 11:26
  • If you need help with the code you can post it here. If you're looking for a different way: Magento does not have a method like that out of the box – Sander Mangel May 7 '15 at 11:33
2

First get the configurable product:

$productId = 100;//change this to what you need
$conf = Mage::getModel('catalog/product')->load($productId);
$productIds = $conf->getTypeInstance()->getUsedProductIds();
//delete the simple products
foreach ($productIds as $id) {
    $product = Mage::getModel('catalog/product')->load($id)->delete();
}
//delete the conf product 
$conf->delete();

I know this is no the fastest way to do it and it uses load in loops but if you don't need to delete hundred of products or you don't need to call this constanlly you should be OK

  • so it seems that this is the way to delete associated products with the configurable product... thanks – Mag-Newbie May 7 '15 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.