1

Just wondering how do I disable a simple product automatically when a configurable product is disabled?

Some times the products we have, we want to disable on our website however a configurable product has over 5-8 simple products associated to it. When I disable configurable product, simple product still stays enabled!

Any suggestion to make it automatically disable associated product?

Thanks

  • You can use mass edit to change status of all products at once. – Priyank Feb 25 '17 at 9:51
1

Use Magento event-observer

catalog_product_save_after

<catalog_product_save_after>
        <observers>
            <yourmodule>
                <type>singleton</type>
                <class>yourmodule/observer</class>
                <method>catalog_product_save_after</method>
            </yourmodule>
        </observers>
</catalog_product_save_after>

in your observer

public function catalog_product_save_after($observer)
{
    $product = $observer->getProduct();
    if( $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE ){

        $childProducts = Mage::getModel('catalog/product_type_configurable')
            >getUsedProducts(null,$product);

        foreach($childProducts as $child) {
            $child->setStatus(Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
            $child->save();
        }
    }
}

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.