Adding a category attribute in Magento

November 10, 2011

I was looking for a code in order to create category attributes in Magento and found a post from Mukesh Chapagain where he explains in a really easy way how to do so. But it didn’t work for me. I’m supposing that the problem is the way how we call the installer in the mysql php file. So I want to explain here, step by step, how I did to make it work:

Create the module

Create a file YourCompany_CategoryAttribute.xml file with the following code and place it in your app/etc/modules folder:

Now create the folder structure for your module. Basically, you need to create the folders: app/code/local/YourCompany/etc and app/code/local/YourCompany/sql/categoryattributesetup. In the first one you have to place a config.xml with this content: