0

A product has an attribute with a list of values A, B, C, ...

When saving the product, I want to compare the first letter of the product names with a list of attribute values. If the attribute value coincided with the first letter of the product, save this value.

How can I do that?

3

Try

Creating an observer for catalog_product_save_before

<global>
    <events>          
        <catalog_product_save_before>
            <observers> 
                <mymodule>
                    <type>singleton</type>
                    <class>mymodule/observer</class>
                    <method>catalog_product_save_before</method>
                </mymodule>
            </observers>

In your observer

class MyNamespace_MyModule_Model_Observer {

public function catalog_product_save_before($observer)
{
    $product = $observer->getProduct();

    //check name
    if($product->getName()){
        //then set value
    }
}

}

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.