There are various ways of retrieving a Magento category attribute, however depending on how it’s stored in the database you can’t always rely on the same method each time.

Let’s say for example that you want to get the meta_description value for a category in the category view template, this field is a native attribute that exist as a column in the catalog_category_flat_store_1 table, so calling one of the following methods would work fine:

But what if you want to get the value of a custom category attribute? Well, the above methods simply won’t work, as custom attributes are usually stored in the eav_attribute table.

The following custom function will retrieve the value of any Magento native category attribute or custom category attribute, just add it the appropriate block or helper class of your module:

The function will except either a category model or category id along with the attribute code and return the attribute value. If the attribute is stored as a multiselect field, the values will be returned as an array instead.

Example template usage




Notify of