Friday 13 June 2014

Magento Create Custom Attribute in Category

1) Yes / No Dropdown

<?php

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$setup->addAttribute('catalog_category', 'is_catalog', array(
   'type' => 'int',
    'group' => 'General',
    'backend' => '',
    'frontend' => '',
    'label' => 'Is Catalog ',
    'input' => 'select',
    'class' => '',
    'source' => 'eav/entity_attribute_source_boolean',            // Leave blank for input type text box
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible' => true,
    'required' => false,
    'user_defined' => false,
    'default' => '0',  //Leave blank for input type text box
    'searchable' => false,
    'filterable' => false,
    'comparable' => false,
    'visible_on_front' => false,
    'unique' => false
));
$installer->endSetup();

2) Textbox

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$setup->addAttribute('catalog_category', 'my_attribute', array(
'group' => 'General',
'input' => 'text',
'type' => 'varchar',
'label' => 'My Attribute',
'backend' => '',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
$installer->endSetup();


No comments:

Post a Comment