Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to create category attribute ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 39
    Comment on it

    Magento provides a way to add product attribute from admin but sometime we need to add category attribute in our category settings. So here I am going to tell you the way we need to create category attribute programmatically.E.g. I am creating one age restriction attribute for some categories. Before start we need to be clear about the files we needed to create attribute. Below are the folders and files we will create -

    1) app/code/local/Evon/CategoryAttr/etc/config.xml
    2) app/code/local/Evon/CategoryAttr/sql/custom_attribute/mysql4-install-0.1.0.php
    3) app/etc/modules/Custom_CategoryAttr.xml

    1) First we will create module file Custom_CateogryAttr.xml in "app/etc/modules/" folder with the following content -

    <?xml version="1.0"?>

    2) Then we will create config.xml in "app/code/local/Custom/CategoryAttr/etc/" folder with the following content -

    <?xml version="1.0"?>

    3) Then we need to create sql file which will enter attribute in database with name mysql4-install-0.1.0.php in "app/code/local/Custom/CategoryAttr/sql/category_attribute/" folder with the following content -

    $this->addAttribute( Mage_Catalog_Model_Category::ENTITY, 'custom_attribute', array(
        'group'         => 'General Information',
        'input'         => 'select',
        'type'          => 'int',
        'label'         => 'Age Restriction',
        'backend'       => '',
        'visible'       => true,
        'required'      => false,
        'visible_on_front' => false,
        'option' => array ('values' => array(
                0 => 'No',
                1 => 'Yes',
        'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,

    Now after executing the file you will see the Age Restriction attribute under General Information tab in category detail page.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: