Necesito agregar a la categoría un atributo personalizado, una selección con 2 valores:
- 0 - "No"
- 1 - "Sí"
Creé un módulo y usé este código en el archivo de instalación:
$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();
El atributo aparece en el panel de administración pero el valor agregado en la selección para "No" es 3 y para "Sí" es 4. ¿Cómo hacer que el valor 0 y 1?
magento-1.7
usuario4157
fuente
fuente
Respuestas:
Prueba esto:
Agregué en
eav/entity_attribute_source_boolean
cuantosource
a su atributo.fuente
eav/entity_attribute_source_boolean
para la opción de selección múltiple?Yes/No
.Intente usar el siguiente código para crear el atributo top_brand en la categoría:
fuente
Para agregar el atributo personalizado sí / no en la sección de categoría, cree el módulo e ingrese el siguiente código.
Por favor, consulte mi tutorial también.
http://www.pearlbells.co.uk/how-to-add-custom-attribute-dropdown-to-category-section-magento/ (sí / no) atributo
http://www.pearlbells.co.uk/how-to-add-custom-dropdown-attribute-to-magento-category-section/ (opciones personalizadas)
fuente