Magento 1

Setting Category & Product Attribute Defaults in Magento 1

When creating a new attribute, we can specify a default value to be saved alongside that attribute. However, these values do not propagate to categories or products which already exist. We can, however use load_after events to remedy this.

Confix XML


Note: To set the default of a category use catalog_product_load_after instead

class Namespace_Module_Model_Observer
    public function setDefaults($observer)
        $category = $observer->getCategory();

        if($category->getShowSizeRollover() === NULL){

In this example we set the attribute ‘show_size_rollover’ to true if it’s not already been given a value. Because we’ve added this event in the global space, this value will propagate for both frontend and adminhtml.