Reputation: 1251
I have a multiselect
attribute in my categories named location
How do I display the selected / saved values on the frontend?
Thanks
Upvotes: 0
Views: 480
Reputation: 158
register an ovserver in magento via xml:
<events>
<catalog_category_flat_loadnodes_before>
<observers>
<category_add_attribute>
<type>model</type>
<class>myModule/observer_catalog_category</class>
<method>addMenuAttributes</method>
</category_add_attribute>
</observers>
</catalog_category_flat_loadnodes_before>
</events>
and then in your Class
class MyModule_Namespace_Model_Observer_Catalog_Category
{
public function addMenuAttributes( Varien_Event_Observer $observer )
{
$observer->getSelect()->columns(
array( 'custom_attribute_name' )
);
}
}
add the customAttribute
Upvotes: 1
Reputation: 158
you have to add the attribute to the colleciton via event: "catalog_category_flat_loadnodes_before"
$observer->getSelect()->columns(
array( 'location' )
);
Upvotes: 1
Reputation: 15206
Try this:
$category->getResource()
->getAttribute('location')
->getSource()
->getOptionText($category->getData('location'))
Upvotes: 1