I need to add to category a custom atribute , a select with 2 values:
- 0 – "No"
- 1 – "Yes"
I created a module and used this code in installation file:
$this->startSetup();
$this->addAttribute('catalog_category', 'top_brand', array(
'group' => 'General',
'type' => 'int',//can be int, varchar, decimal, text, datetime
'backend' => '',
'frontend_input' => '',
'frontend' => '',
'label' => 'Top Hersteller',
'input' => 'select', //text, textarea, select, file, image, multilselect
'option' => array(
'value' => array(
'optionone'=> array(
0 =>'No'),
'optiontwo'=> array(
0 =>'Yes')
),
),
'default' => array(0),
'class' => '',
// 'source' => '',//this is necessary for select and multilelect, for the rest leave it blank
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,//scope can be SCOPE_STORE or SCOPE_GLOBAL or SCOPE_WEBSITE
'visible' => true,
'frontend_class' => '',
'required' => false,//or true
'user_defined' => true,
'default' => '',
'position' => 100,//any number will do
));
$this->endSetup();
Attribute appear in administration panel but value added in select for "No" is 3 and for "Yes" is 4.
How to make value 0 and 1 ?
Best Answer
Try this:
I added
eav/entity_attribute_source_boolean
assource
for your attribute.