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
<global> <events> <catalog_category_load_after> <observers> <observer_name> <type>singleton</type> <class>module/observer</class> <method>setDefaults</method> </observer_name> </observers> </catalog_category_load_after> </events> </global>
Note: To set the default of a category use catalog_product_load_after instead
<?php class Namespace_Module_Model_Observer { public function setDefaults($observer) { $category = $observer->getCategory(); if($category->getShowSizeRollover() === NULL){ $category->setShowSizeRollover(true); } } }
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.