• Home
  • >
  • Magento
  • >
  • How To Add Attributes for Categories in Magento

How To Add Attributes for Categories in Magento

The Magento admin panel lets you add attributes only for products. If you want to add attributes to a category, here’s what you have to:

You have to write sql query in your phpmyadmin or better still, create a new custom module and add attributes to the category from the mysql setup file of the module.

In this post, we’ll show you how to add a new custom category attribute in Magento.

First, you have to create a new module to add a custom category attribute, let’s call it “Custom Category Attribute”.

Step 1. Create new module.

Initial configuration file is located in ‘app/etc/modules/Dat_CustomCategoryAttribute’. Dat_CustomCategoryAttribute

It means that the module is active and it is located in the local code pool.

Step 2. Configure module.

Module configuration file is located in “app/code/< code pool>/< name space>/< module name>/etc” and its name is config.xml – note, that in this case this looks like ‘app/code/local/Dat/CustomCategoryAttribute/etc/config.xml’. Config.xml

As you can see, the configuration file is not large at all, there are only 2 nodes: one is module version and the other is resources for install script. The install script helps us to create a new attribute. In the node we defined the class for our install script which will be used for the extension. Working with methods of this class helps us create, update, remove attribute (etc). And the node says that the script must be located in the folder with the same name (in this case path will be ‘app/code/community/Dat/CustomCategoryAttribute/sql/add_category_attribute’)

Step 3. Create attribute.

Another vital thing is creating install script file in the folder ‘add_category_attribute’. Since the file name depends on the module version, it looks like this: ‘mysql4-install-x.x.x.php’, where x.x.x is the version of the module. Mysql4-install-0.0.1.php

As a result, we created a new attribute in the category with label ‘Custom attribute ‘. This attribute is a text and it must be visible on the frontend. Check this out!

Step 4. Check result.

Here, let’s clear cache and after this, go to Admin Panel –> Catalog –> Manage Categories –> General Information tab you will see a new attribute: ‘Custom attribute’.

blog1

Moreover, to see the content from ‘Custom attribute’ on the frontend in the category page – you need to go of this page (‘app/design/frontend/< package> /< theme>/template/catalog/category/view.phtml’), check please the following code:

April 22 , 2016

Digital Aptech

This entry was posted in Magento

Why Hire Us?

  • Awarded with "Fastest growing Indian company excellence award" at 8th International Achievers Conference at Bangkok, Thailand.
  • Featured as the "Company of the Month" in December 2016 in India's premier IT magazine, Silicon India having significant circulation in US and in India.
  • Featured among the "20 most promising Digital Marketing Solution Providers in India in 2016" in the prestigious entrepreneur magazine in India
  • ISO 9001:2008 Certified & RAR+ Recommended Company
  • Around 200+ In-house Employee and 800+ Years Of Collective Experience
  • 1500+ Digital Projects Delivered
  • Savings of up to 50% on your project cost
  • Assured monthly work production of 160 hours Guaranteed
  • Total Project Management Control
  • 9000 sq. ft. State-of-the-art Facilities & Infrastructure
  • Work with Your OWN remote team
  • 24x7 Availability when required
  • We Sign NDA for Confidentiality, All Rights Are Owned By You
  • Profitable Since Inception. US$ 2Million turnover

Projects VS DRM!

This is a Detailed Breakdown of the Advantages that the Dedicated Resource Model vis-à-vis the Conservative Project Model. Read More...

Quick Contact

Keep in touch at

Ourlocations

We are here to help you and would love to hear from you, so please feel free to contact us.


US Office

Visit Us

193 Twilight Terrace Bailey,
CO 80421
(Greater Denver Area)

Tel: +1-650 481 6031


UK Office

Visit Us

Box 4343,Office 6 Slington House,
Rankine Road, BASINGSTOKE,
RG24 8PH, United Kingdom

Tel: +44 20 79932099


India Development Office

Visit Us

EN-34 (9th Floor),
Block-EN, Sector - V,
Salt Lake City, Kolkata - 700091, West Bengal, India

Tel: +91 33 69000863 / 69


Australia Office

Visit Us

25, Ashbury Grove,
Hillside
Australia – 3037

Tel: +61 433 134 786