您好我需要在订单网格中显示产品skus,为此我添加了以下查询
$collection->getSelect()->join('sales_flat_order_item', 'sales_flat_order.entity_id = sales_flat_order_item.order_id',array('sku'=>'sku'));
中的
_prepareCollection()
但是这给了我以下错误
Item (Mage_Sales_Model_Order) with the same id "1537254" already exist
请建议我在哪里做错了或者我怎么能得到这个。谢谢
答案 0 :(得分:1)
将此代码用于产品sku
$collection->getSelect()->joinLeft('sales_flat_order_item', 'sales_flat_order_item.order_id = main_table.entity_id', array('skus' => new Zend_Db_Expr('group_concat(sales_flat_order_item.sku SEPARATOR ", ")')));
$collection->getSelect()->group('main_table.entity_id');
在grid.php文件中添加列
$this->addColumn("skus", array(
"header" => Mage::helper("catalog")->__("SKU"),
"index" => "skus",
));