Magento – How to Remove Associated Products from Configurable Product

associated-productsconfigurable-productproduct

I want to remove all associated product from configurable product .

How can i do this

I m trying to do like this

$product = Mage::getModel('catalog/product')->load(11);
$product->getTypeInstance()->setUsedProductAttributeIds();
$product->save();

but its not working

Best Answer

use the below code:

Mage::getResourceSingleton('catalog/product_type_configurable')
    ->saveProducts($product, array());

Send saveProducts() second params as empty arrya

Your code like this:

$product = Mage::getModel('catalog/product')->load(11);
Mage::getResourceModel('catalog/product_type_configurable')
    ->saveProducts($product, array());