在后台产品列表页添加自定义的属性,实现可以检索
app\code\core\Mage\Adminhtml\Block\Catalog\Product\Grid.php(建议进行重写)
我这里添加的属性measuring_paragraph是Dropdown属性,其他属性的需要自己进行修改
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('sku')
->addAttributeToSelect('name')
->addAttributeToSelect('attribute_set_id')
->addAttributeToSelect('type_id')
->addAttributeToSelect('measuring_paragraph');
$this->addColumn('measuring_paragraph',
array(
'header'=> Mage::helper('catalog')->__('Measuring Paragraph'),
'width' => '70px',
'index' => 'measuring_paragraph',
'type' => 'options',
'options' => $this->_getProductAttributeOptions('measuring_paragraph'),
));
protected function _getProductAttributeOptions($attributeName)
{
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attributeName);
/* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
$attributeOptions = $attribute->getSource()->getAllOptions();
$options = array(); // options in key => value Format bringen
foreach ($attributeOptions as $option) {
if(!empty($option['value']))
{
$options[number_format($option['value'], 4, '.', '')] = $option['label'];
}
}
return $options;
}