Magento 1.9: Add custom attribute to category

Published on 27 Feb 2017 , edited on 22 Mar 2019

Step 1. Init module

Step 2. Create config

Step 3. Create SQL script

Make sure the filename and path match the version (0.0.1) and nodenames (add_category_attribute) of the config.xml from Step 2.

If you change anything in the module, you can update it with a new version number. In this case you’ll have to add a new SQL script with the correct filename (i.e. from 0.0.1 to 0.0.2):

If for some reason the changes don’t show and reinstalling/renaming the module doesn’t work, it’s because the add_category_attribute is added in the core_resource table. Delete that record from the database and try again; it should show up now.

To show the field on the frontend, do this:
getCurrentCategory()->getCustomAttribute()): ?>
    categoryAttribute($_category, $_customAttribute, 'custom_attribute') ?>

or this
echo $_category->getData("custom_attribute");


Everything web development related, rants, snippets, tutorials, quests; it’s all there.

All categories

All tags

All posts