custom attribute code in magento



For Text
<?php
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
// below code will add text attribute
$setup->addAttribute('catalog_category', 'Lady', array(
'group'         => 'General',
'input'         => 'text',
'type'          => 'varchar',
'label'         => 'Lady',
'visible'       => 1,
'required'      => 0,
'user_defined' => 1,
'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
?>

For Image 
<?php 
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$setup->addAttribute('catalog_category', 'image1', array(
    'input'         => 'image',
    'type'          => 'file',
    'group' => 'General',
    'label'         => 'Additional image 1',
    'visible'       => 1,
    'required'      => 0,
    'user_defined' => 1,
    'frontend_input' =>'',
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible_on_front'  => 1,
));

?>

Comments