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 magento.stackexchange.com, 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 community@magento.com.

Magento Forum

Can’t navigate to 2nd page of order results after adding SKU column to order Grid.php
 
DenverTiger
Jr. Member
 
Total Posts:  4
Joined:  2013-01-11
 

I have successfully added the SKU column to my order grid, and am able to sort/filter by SKU. When the code is implemented, there is only one page of results available, even though there are 40,000k orders in the system. When I sort by a specific order status, it may show 150+ orders, but it only says there are 3-5 records.

Below is the code that is causing the problem, but I can\’t figure out why.

{
        $collection 
Mage::getResourceModel($this->_getCollectionClass())
            ->
join(
                
\'sales/order_item\',
                
\'`sales/order_item`.order_id=`main_table`.entity_id\',
                array(
                    
\'sku\'  => new Zend_Db_Expr(\'group_concat(`sales/order_item`.sku SEPARATOR \",\")\'),
                    
\'names\' => new Zend_Db_Expr(\'group_concat(`sales/order_item`.name SEPARATOR \",\")\'),
                    )
                );
                
$collection->getSelect()->group(\'entity_id\');
 
            
$this->setCollection($collection);
        return 
parent::_prepareCollection();
    
}

Any input would be great!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ryan Sun _Kuafu
Guru
 
Total Posts:  317
Joined:  2008-11-14
FL
 

getSelectCountSql() does not reset group, so you have to rewrite Mage_Sales_Model_Mysql4_Order_Grid_Collection and make getSelectCountSql() to reset group also

 
Magento Community Magento Community
Magento Community
Magento Community
 
DenverTiger
Jr. Member
 
Total Posts:  4
Joined:  2013-01-11
 

Ryan,

Thanks for the reply, but I’m not quite at that level of understanding just yet. Could you give me a few more tips on how to accomplish this?

Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ryan Sun _Kuafu
Guru
 
Total Posts:  317
Joined:  2008-11-14
FL
 

1, rewrite Mage_Sales_Model_Mysql4_Order_Grid_Collection class in app/core/Mage/Sales/Model/Mysql4/Order/Grid/Collection.php,
if you don’t know how, just hack this file
2, place this function in your custom rewrite file or the hacked core file

public function getSelectCountSql()
    
{
        
/* @var $countSelect Varien_Db_Select */
        
$countSelect parent::getSelectCountSql();

        
$countSelect->reset(Zend_Db_Select::GROUP);
        return 
$countSelect;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
DenverTiger
Jr. Member
 
Total Posts:  4
Joined:  2013-01-11
 

Followed your details with no luck. Still unable to go to the next page.

Any other thoughts?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ryan Sun _Kuafu
Guru
 
Total Posts:  317
Joined:  2008-11-14
FL
 

Enable sql log and find out the select count statement (should be a sql start with select sum) and see why its not counting correctly

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