【发布时间】:2023-04-06 12:30:01
【问题描述】:
我正在运行 Magento Community 1.6.2
我正在尝试编辑我的销售订单网格,以便单个项目(属于多个项目订单的一部分)出现在各自的行中。
我添加到 Grip.php 中的 prepareCollection 函数(首先要操作这些列)如下:
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass())
->join(
'sales/order_item',
'`sales/order_item`.order_id=`main_table`.entity_id',
array(
'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR "<br>")'),
'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR "<br>")'),
'quantities' => new Zend_Db_Expr('group_concat(`sales/order_item`.qty_ordered SEPARATOR "<br>")'),
)
);
$collection->getSelect()->group('entity_id');
$this->setCollection($collection);
return parent::_prepareCollection();
}
我已使用以下内容添加了列:
$this->addColumn('skus', array(
'header' => Mage::helper('Sales')->__('SKUs'),
'width' => '120px',
'index' => 'skus',
'type' => 'text',
));
$this->addColumn('names', array(
'header' => Mage::helper('Sales')->__('Item Names'),
'width' => '320px',
'index' => 'names',
'type' => 'text',
));
$this->addColumn('quantities', array(
'header' => Mage::helper('Sales')->__('Quantities'),
'width' => '100px',
'index' => 'quantities',
'type' => 'text',
));
目前,在函数中,我只是简单地输入了<br>,以便在查看订单网格时呈现单独的线条。这不足以满足我的需求。我计划使用从该网格导出的 CSV,并且绝对必须将逐项列出的订单组件放在单独的行上。
感谢您的帮助!
【问题讨论】:
-
你解决了吗?
标签: mysql magento zend-db magento-1.6