-
- kimball1

-
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:
app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
to
app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php
Then I altered the new local copy of Grid.php to have a totally new _prepareCollection() as follows:
protected function _prepareCollection() { $separatorStyle = "border:0;border-bottom:1px dashed #aaa;"; $collection = Mage::getResourceModel($this->_getCollectionClass()) ->join( 'sales/order_item', '`sales/order_item`.order_id=`main_table`.entity_id', array( '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>")'), ) ); $collection->getSelect()->group('main_table.entity_id');
$collection->getSelect()->joinLeft(array('sfo'=>'sales_flat_order'), 'sfo.entity_id=main_table.entity_id',array('sfo.customer_email','sfo.weight', 'sfo.discount_description','sfo.increment_id','sfo.store_id','sfo.created_at','sfo.status', 'sfo.base_grand_total','sfo.grand_total', 'sfo.base_shipping_amount')); $this->setCollection($collection); return parent::_prepareCollection(); }
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?
Thanks!
|