我想添加带有属性(颜色,大小)的产品名称。但使用下面的代码总记录后只显示2条记录。这是我的代码: 文件名是:app / code / local / Mage / Adminhtml / Block / Sales / Order / Grid
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->joinLeft('sales_flat_order', 'main_table.entity_id = sales_flat_order.entity_id',array('customer_email'=>'customer_email'));
$collection->getSelect()->joinLeft('sales_order_status', 'sales_flat_order.status=sales_order_status.status',array('label'=>'label'));
$collection->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'product_name' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ",")'),
)
);
$collection->getSelect()->group('entity_id');
//$collection->getSelect()->join('sales_flat_order_address', 'main_table.entity_id = sales_flat_order_address.parent_id AND sales_flat_order_address.address_type = "shipping" ',array('telephone', 'email'));
//var_dump((string)$collection->getSelect());
$this->setCollection($collection);
return parent::_prepareCollection();
}
和函数_prepareColumns()
$this->addColumn('product_name', array(
'header' => Mage::helper('Sales')->__('Product Name'),
'width' => '100px',
'index' => 'product_name',
'type' => 'text',
));
请帮助我如何添加带有产品名称的属性?