Delete all custom option before product save


add below function in observer and add event in your config file.catalog_product_save_before

 public function deleteCustomOption(Varien_Event_Observer $observer){
 $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