2012-04-26 55 views
0

我需要添加客户的'公司'属性发票网格。 下面是我更改的代码,它在phpmyadmin中显示正确的查询结果,但不知何故,它只显示2作为发票网格上的Total记录。Magento发票网格新专栏问题

protected function _prepareCollection() 
{ 
    $collection = Mage::getResourceModel($this->_getCollectionClass()); 
    $collection->getSelect()->joinInner(array('order_address' => Mage::getSingleton('core/resource')->getTableName('sales_flat_order_address')),'order_address.parent_id = main_table.order_id',array('company'))->group('parent_id')->order('entity_id', 'desc'); 

    $this->setCollection($collection); 
    return parent::_prepareCollection(); 
} 

和查询

SELECT `main_table`.*, `order_address`.`company` FROM `sales_flat_invoice_grid` AS `main_table` INNER JOIN `sales_flat_order_address` AS `order_address` ON order_address.parent_id = main_table.order_id GROUP BY `parent_id` 

如果我改变的记录200每页数,它显示了所有的记录,但在寻呼和总记录一些问题。

它总是显示1页和'共找到2条记录'。所以我不能移动到下一页。

请帮忙。

谢谢

回答

0

用于具有破碎管理网格寻呼机问题的任何一个,这里是解决方案。

从Magento的

复制db.php中的文件/ lib中/瓦瑞恩/数据/收集/ db.php中 将其粘贴到本地目录,这样所得到的文件夹结构是这样的: 的Magento /应用/代码/本地/瓦瑞恩/ Data/Collection/Db.php

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; 
} 
+0

你为什么不称赞这个答案的原作者? http://stackoverflow.com/a/4219386/927404 – 2012-09-12 12:09:32