Magento Development, Customization, Extension Development and Integration, Optimization, API Integration, SEO and Responsive Design

Create new custom category attribute in Magento

There is no option in magento to add new custom category attribute. So if you want to add new category attribute in your magento you need to make some kind of code. Adding new custom attribute in magento using short code as following is short but not much more secure and proper way.

If you want to create new category attribute in proper way via module you can check my post
Adding Custom Category Attributes to Magento via Module

Copy and paste the following code in your header.phtml

$installer = new Mage_Sales_Model_Mysql4_Setup;
$attribute  = array(
    'type' => 'int',
    'label'=> 'Your attribute label',
    'input' => 'text',
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible' => true,
    'required' => false,
    'user_defined' => true,
    'default' => "",
    'group' => "General Information"
$installer->addAttribute('catalog_category', 'your_attribute_code', $attribute);

Run your site once. After that remove this code from header.phtml
Your attribute is created.

its appear in your catalog->manage categories->General information tab

  1. I am not getting "your_attribute_code" value in the following function,
    I want to get the value

    1. You can get the value of custom category attribute in category/view.phtml as


  2. This worked great, thanks :)

    Would you provide information on how to install this as a real module in Magento? That would be great and less "hacky" :)

  3. This is excellent one!! It works. :)

  4. Hi, can you help me to remove custom attr :) because I created two identical attribute



Copyright @ 2015 HK Magento Blog.