覆盖magento订单网格后,分页不起作用?

Suk*_*ini 1 php magento-1.7

我已经覆盖了Mage_Adminhtml_Block_Sales_Order_Grid添加extral 3列,如下所示.

  1. 客户电邮
  2. 支付方式
  3. 订购产品

我的扩展网格类如下.

<?php
class Wowmall_ExtendedGrid_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{

    protected function _getCollectionClass()
    {
        return 'sales/order_grid_collection';
    }

    protected function _prepareCollection()
    {   
       $collection = Mage::getResourceModel($this->_getCollectionClass());
       $collection->getSelect()
                   ->joinLeft('sales_flat_order_payment', 'main_table.entity_id = sales_flat_order_payment.parent_id','method')
                   ->join('customer_entity', 'main_table.customer_id = customer_entity.entity_id','email')
                   ->join('sales_flat_order_item', 'main_table.entity_id = sales_flat_order_item.order_id','name')->distinct(true);

         $collection->getSelect()->group('main_table.entity_id');

         $this->setCollection($collection);
        return $this;
    }

    protected function _prepareColumns()
    {

       // rest code...

        $this->addColumn('email', array(
            'header' => Mage::helper('sales')->__('Customer Email'),
            'index' => 'email',
            'type' => 'text',
        ));

        $this->addColumn('method', array(
        'header'    => Mage::helper('sales')->__('Payment Type'),
        'index'     => 'method',
        'type'      => 'options',
        'options'   => array('verisign' => 'Credit Card', 'checkmo' => 'Check', 'purchaseorder' => 'Purchase Order'),
    ));

         $this->addColumn('name', array(
            'header' => Mage::helper('sales')->__('Product(s) Ordered'),
            'index' => 'name',
            'type' => 'text',
        ));

       // rest code...
Run Code Online (Sandbox Code Playgroud)

但是分页不起作用.所有记录都在一个页面中加载.请问有什么建议?

Suk*_*ini 5

我自己找到了解决方案.

由于以下声明而发生此问题.

$collection->getSelect()->group('main_table.entity_id');
Run Code Online (Sandbox Code Playgroud)

我编辑了 lib/Varien/Data/Collection/Db.php

我的Db.php文件位于 app/code/local/Varien/Data/Collection/Db.php

以下是代码.

.....//rest code

public function getSelectCountSql()
    {
        $this->_renderFilters();

        $countSelect = clone $this->getSelect();
        $countSelect->reset(Zend_Db_Select::ORDER);
        $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
        $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
        $countSelect->reset(Zend_Db_Select::COLUMNS);

        if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
            $countSelect->reset(Zend_Db_Select::GROUP);
            $countSelect->distinct(true);
            $group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
            $countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
        } else {
            $countSelect->columns('COUNT(*)');
        }
        return $countSelect;
    }
....//rest code
Run Code Online (Sandbox Code Playgroud)

然后清除缓存和会话后它工作.. :)