1
我正嘗試使用Grid.php添加在管理中訂單網格的產品。將訂單項添加到Magento中的訂單網格
app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid.php
我已經爲此視圖添加了另一個客戶屬性。當我添加產品列表時,發現的訂單數始終設置爲1,並且不會讓我進入訂單的下一頁。
這是我已成功地添加代碼。
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->join('sales_flat_order_item', '`sales_flat_order_item`.order_id=`main_table`.entity_id', array('name' => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.name SEPARATOR ", ")')));
$collection->getSelect()->group('entity_id');
$collection->getSelect()->joinLeft(
array('cev' => 'customer_entity_varchar'),
'(main_table.customer_id = cev.entity_id AND cev.attribute_id = 141 AND main_table.customer_id IS NOT NULL)',
array(
'admin_number' => 'cev.value',
)
);
$this->setCollection($collection);
return parent::_prepareCollection();
}
$this->addColumn('admin_number', array(
'header' => Mage::helper('sales')->__('Admin Number'),
'filter_index' => 'cev.value',
'index' => 'admin_number'
));
$this->addColumn('name', array(
'header' => Mage::helper('Sales')->__('Products'),
'width' => '100px',
'index' => 'name',
'type' => 'text',
));
希望有人能幫我看看有什麼不對。
你能解釋一下你從原始代碼改變了什麼嗎? –
$ rows = $ connection-> fetchAll($ sql); // fetchRow($ sql),fetchOne($ sql),... // Zend_Debug :: dump($ rows); $ pk = 0; foreach($ rows as $ value){ $ pkorder [] = $ rows [$ pk] ['order_id']; $ pk ++; } – user2185477