Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Altering Sales Grid Breaks Pagination
Jr. Member
Total Posts:  11
Joined:  2011-04-02

Our sales fulfillment staff wanted to see different columns in the sales grid to make fulfilling orders easier.  After doing a bunch of research and finding similar changes others had made, I copied:

Then I altered the new local copy of Grid.php to have a totally new _prepareCollection() as follows:

protected function _prepareCollection()
"border:0;border-bottom:1px dashed #aaa;";
$collection Mage::getResourceModel($this->_getCollectionClass())
'skus'  => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR "<BR><BR>")'),
'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR "<BR><BR>")'),


Then I altered prepareColumns() to handle the new columns from the above _prepareCollection() (I’d paste that method here as well, but it is too large for a forum post.)

After making these changes, the new fields appear in the grid on the sales->Orders grid, and the fulfillment staff began to sing my praises.  However, this also broke the pagination.  Our store has well over 10k orders over the years, but if you go to the sales->Orders grid, the pagination always shows page 1 of 1.  If you select to show 50 orders per page, it loads and shows 50 orders, indicating page 1 of 1.  If you tell it to show 200 orders per page, it shows 200 orders, indicating page 1 of 1.

If I revert my local changes to match the original core Grid.php, the pagination works as expected, but of course then my custom fields are removed from the grid.

How do I get it to paginate correctly with custom fields in that grid?


Magento Community Magento Community
Magento Community
Magento Community
Total Posts:  33
Joined:  2010-01-15

Hi kimball1,

Please remove group() method. I hope this will solve your problem.

When you use group by Magento call the method

public function getSize()
if (is_null($this->_totalRecords)) {
$this->_totalRecords $this->getConnection()->fetchOne($sql$this->_bindParams);
return intval($this->_totalRecords);

you can find this in the library, Varien_Data_Collection_Db

In the If you use count() with group by you’ll get a result containing the number of items for each group.

Also you can follow this thread:

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top