Delete all custom option on catalog_product_save_before event using observer


Hope you have configure observer for this event.if not please configure and add below code to it.

$product            = $observer->getProduct();
if ($product->getId()) {
            $productMod = Mage::getModel('catalog/product')->load($product->getId());
            $opt        = $productMod->getOptions();
            foreach ($opt as $o) {
                /** delete the selected custom option **/
                $o->getValueInstance()->deleteValue($o->getId());
                $o->deletePrices($o->getId());
                $o->deleteTitles($o->getId());
                $o->delete();
            }
        }
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s