0

I have a product with custom option of text area type. now i want to set some default text which should be use when user doesn't fill any text and this text will go to cart with product.

I have searched everywhere but not getting how to do this ?

Please help if anyone know about this.

1

You can do this via observer in custom module:

<?xml version="1.0"?>
<config>
    <!-- some config here -->
    <adminhtml>
        <events>
            <catalog_product_prepare_save>
                <observers>
                    <my_module_observer_node>
                        <type>singleton</type>
                        <class>My_Module_Model_Observer</class>
                        <method>catalogProductPrepareSave</method>
                    </my_module_observer_node>
                </observers>
            </catalog_product_prepare_save>
        </events>
    </adminhtml>
    <!-- some config here-->
</config>

And Model/Observer.php

class My_Module_Model_Observer
{
    public function catalogProductPrepareSave($observer)
    {
        /**
         * @var $product Mage_Catalog_Model_Product
         */
        $product = $observer->getEvent()->getProduct();
        if(!$product->getSomeAttribute()){
            $product->setSomeAttribute("Some default value here");
        }
    }
}
| improve this answer | |

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.