B-219 Sec-55 Noida, India
+918010221733

How to add new custom category attribute in Magento

To create the custom attribute for category we have two option

1) Make a copy of your app/code/core/Mage/Catalog/sql/catalog_setup and change the name of your copied folder and put the mysql4-install-1.4.0.0.0.php
Like you wan to create a extra image attribute for a category then first you have to copy the catalog_setup and paste it into the  app/code/core/Mage/Catalog/sql/ then you will change the name catalogimage_setup and put mysql4-install-1.4.0.0.0.php paste the below code

<?php
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);
$setup->addAttribute(‘catalog_category’, ‘image1’, array(
    ‘input’         => ‘image’, // you can change here
    ‘type’          => ‘varchar’,
    ‘group’ => ‘General Information’,/// Change here whare you want to show this
    ‘label’         => ‘Additional Image for Mouse hover’,
    ‘visible’       => 1,
    ‘backend’ => ‘catalog/category_attribute_backend_image’,
    ‘required’      => 0,
    ‘user_defined’ => 1,
    ‘frontend_input’ =>”,
    ‘global’        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    ‘visible_on_front’  => 1,
));
?>
After it got to app/code/core/Mage/Catalog/etc/config.xml
then find the
 <catalog_setup>
                <setup>
                    <module>Mage_Catalog</module>
                    <class>Mage_Catalog_Model_Resource_Setup</class>
                </setup>
</catalog_setup>

make a copy of the above line and paste it just after
 with your setup name
<catalogimage_setup>
                <setup>
                    <module>Mage_Catalog</module>
                    <class>Mage_Catalog_Model_Resource_Setup</class>
                </setup>
 </catalogimage_setup>

and run the admin site now you attribute has been created.

2)
 Just copy paste the below code in header.phtml and run yourmagento once, your attribute will be created and you can see in backend under manage category. After you are done remove this code again.

 ——————————————————————————————
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);

$setup->addAttribute(‘catalog_category’, ‘sliderimage’, array(
    ‘group’         => ‘General’,
    ‘input’         => ‘image’,
    ‘type’          => ‘varchar’,
    ‘label’         => ‘Slider Image’,
    ‘backend’       => ‘catalog/category_attribute_backend_image’,
    ‘visible’       => 1,
    ‘required’        => 0,
    ‘user_defined’ => 1,
    ‘global’        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));

(Visited 66 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.