【发布时间】:2013-09-28 10:08:52
【问题描述】:
我想在magento的客户网格中显示订单数
我以此为指导: How to add customer "total number of orders" and "total spent" to order grid in 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+)
对此新列的排序不起作用
【问题讨论】: