【发布时间】:2012-10-03 21:14:03
【问题描述】:
我在 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)...
【问题讨论】:
-
其实我有兴趣学习如何创建一个自定义过滤器(如果可能的话)如果你有任何发现请分享信息
标签: magento magento-1.7