2012-04-26 33 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