如何在自定义模块编辑表单中获取制造商下拉列表?
How to get Manufacturer dropdown in custom module edit form?
我想为每个品牌添加图片,为此我创建了一个模块。在模块的编辑表单中,我想要一个制造商下拉列表,这样我就可以将图像分配给特定的 manufacturer/brand。
这是我的编辑表单位置代码:
app/code/local/Root/Brand/Block/Adminhtml/Brand/Edit/Tab/form.php
$fieldset->addField('title', 'select', array(
'name' => 'title',
'label' => 'Brand',
'values' => Mage::getUrl('catalogsearch/advanced/result', array(
'brand' => $option['value']
))
));
$fieldset->addField('filename', 'image', array(
'label' => Mage::helper('brand')->__('Brand Image') ,
'required' => false,
'name' => 'filename',
'note' => '(*.jpg, *.png, *.gif)'
));
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
//here, "brandname" is the attribute_code
$allOptions = $attribute->getSource()->getAllOptions(true, true);
$fieldset->addField('title', 'select', array(
'label' => Mage::helper('brand')->__('Brand Name'),
'name' => 'title',
'values' => $allOptions
));
我想为每个品牌添加图片,为此我创建了一个模块。在模块的编辑表单中,我想要一个制造商下拉列表,这样我就可以将图像分配给特定的 manufacturer/brand。
这是我的编辑表单位置代码:
app/code/local/Root/Brand/Block/Adminhtml/Brand/Edit/Tab/form.php
$fieldset->addField('title', 'select', array(
'name' => 'title',
'label' => 'Brand',
'values' => Mage::getUrl('catalogsearch/advanced/result', array(
'brand' => $option['value']
))
));
$fieldset->addField('filename', 'image', array(
'label' => Mage::helper('brand')->__('Brand Image') ,
'required' => false,
'name' => 'filename',
'note' => '(*.jpg, *.png, *.gif)'
));
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
//here, "brandname" is the attribute_code
$allOptions = $attribute->getSource()->getAllOptions(true, true);
$fieldset->addField('title', 'select', array(
'label' => Mage::helper('brand')->__('Brand Name'),
'name' => 'title',
'values' => $allOptions
));