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
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’.
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
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...