i added "brand" attribute (drop down list) products. i'm trying add new attribute (drop down list) category values "brand" attribute. should set correct source category attribute. please see piece of code in mysql setup file:
$this->startsetup(); $this->addattribute('catalog_category', 'brand', array( 'group' => 'general', 'type' => 'int' 'backend' => '', 'frontend_input' => '', 'frontend' => '', 'label' => 'brand', 'input' => 'select' 'class' => '', 'source' => 'mymodule/selecattributes', 'global' => mage_catalog_model_resource_eav_attribute::scope_global, 'visible' => true, 'frontend_class' => '', 'required' => false, 'user_defined' => true, 'default' => '', 'position' => 100, )); $this->endsetup(); thanks in advance.
edit 1 added class mypackage_mymodule_model_selectattributes extends extends mage_eav_model_entity_attribute_source_abstract :
class mypackage_mymodule_model_selectattributes extends mage_eav_model_entity_attribute_source_abstract{ public function getalloptions() { $attributecode = 'brand'; $attribute = mage::getmodel('eav/config')->getattribute('catalog_product', $attributecode); //here, "color" attribute_code $alloptions = $attribute->getsource()->getalloptions(true, true); foreach ($alloptions $instance) { $myarray[$instance['value']] = $instance['label']; } return $myarray; } } edit 2 when open category admin page error:
"source model "mymodule/selectattributes" not found attribute "brands""
i'm guessing source model in file named selectattributes.php. if using case-sensitive filesystem need 1 of 2 things:
rename class definition file
selectattributes.phpor
change
source_modelvalue brands attributemymodule/selectattributes
when magento attempting instantiate source model attribute, classname (and hence autoload include path) being calculated work follows:
mypackage_mymodule_model_selectattributes mypackage/mymodule/model/selectattributes.php note issue filename. note should working in non-case-sensitive filesystem.
Comments
Post a Comment