我想在magento的客户网格中显示订单数量
我以此为指导: 如何在 magento 1.7 中将客户“订单总数”和“总支出”添加到订单网格中
但这是一个不同的网格
到目前为止我已经创建:app/code/local/Mage/Adminhtml/Block/Customer/Grid.php
_prepareCollection
我补充说:
$orderTableName = Mage::getSingleton('core/resource')
->getTableName('sales/order');
$collection
->getSelect()
->joinLeft(
array('orders' => $orderTableName),
'orders.customer_id=e.entity_id',
array('order_count' => 'COUNT(customer_id)')
);
$collection->groupByAttribute('entity_id');
之前:$this->setCollection($collection);
_prepareColumns 我添加了:
$this->addColumn('order_count', array(
'header' => Mage::helper('customer')->__('# orders'),
'index' => 'order_count',
'type' => 'number'
));
虽然它确实在网格中工作,但我有一些问题:
寻呼机显示 1 个客户(应该是 500+)
在这个新列上排序不起作用