我在 Adminhtml 中有自定义网格。
protected function _prepareCollection()
{
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
$collection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left');
$collection->groupByAttribute('entity_id');
$collection->addStaticField('category_id');
$collection->addExpressionAttributeToSelect('category_grp', 'GROUP_CONCAT(category_id)', 'category_id');
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
parent::_prepareColumns();
$this->addColumn('category_id', array(
'header' => Mage::helper('newsletter')->__('Category'),
'index' => 'category_grp',
'type' => 'categories',
'options' => $options,
'align' => 'left',
// 'filter_index' => $this->_getFlatExpressionColumn('category'),
return $this;
}
category_grp 是带有 int 的数组
我的问题是如何将过滤器添加到从字段中过滤项目的标题列?
例如,仅过滤 category_id=7 的产品(category_grp 为 3、6、7、13)...