Tôi cần thêm vào danh mục thuộc tính tùy chỉnh, chọn với 2 giá trị:
- 0 - "Không"
- 1 - "Có"
Tôi đã tạo một mô-đun và sử dụng mã này trong tệp cài đặt:
$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();
Thuộc tính xuất hiện trong bảng quản trị nhưng giá trị gia tăng trong chọn cho "Không" là 3 và cho "Có" là 4. Làm cách nào để tạo giá trị 0 và 1?