在Magento管理产品网格添加类别栏

Add a column and filter to catalog product grid which has SEVERAL values


->joinField('category_ids',
            'catalog/category_product_index',
            'category_id',
            'product_id=entity_id',
            null,
            'left')

which gives me an error:a:5:{i:0;s:72:"Item (Mage_Catalog_Model_Product) with the same id "16243" already exist"

In prepareColumns I'm adding:

$this->addColumn('category_ids',
        array(
            'header'=> Mage::helper('catalog')->__('Categories'),
            'index' => 'category_ids',
            'width' => '150px'
    ));

How can I fix my query so I won't get the error?Is it possible to show and filter by category names instead of ids?

a forum post show a similar code but I couldn't make it work with categorieshttp://www.magentocommerce.com/boards/viewthread/44534/

static protected $COLUMN_ID_TRADE_REFERENCES = 'ref_text';

protected function _prepareCollection()
{
    $store = $this->_getStore();
    $collection = Mage::getModel('catalog/product')->getCollection()
        ->addAttributeToSelect('name')
        ->addAttributeToSelect('attribute_set_id')
        ->addAttributeToSelect('type_id')
        ->addAttributeToSelect('ref_text')
        ->joinTable('productreferences/reference',
            'product_id=entity_id',
            array('ref_text'),
            null,
            'left')
        ->joinField('qty',
            'cataloginventory/stock_item',
            'qty',
            'product_id=entity_id',
            '{{table}}.stock_id=1',
            'left')
        ->addStaticField('ref_text')
        ->addExpressionAttributeToSelect(self::$COLUMN_ID_TRADE_REFERENCES,
            'GROUP_CONCAT(ref_text SEPARATOR " ; ")',
            'ref_text')
        ->groupByAttribute('entity_id');

Thanks


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值