Magento Order Grid Column Not Found After SUPEE-6788

After applying the pain-in-the-ass Magento secuity patch SUPEE-6788, I encountered a „Column not found: 1054 Unknown column ‚main_table.status‘ in ‚where clause'“ error on the admin order grid. The issue is tough to debug as there are no custom templates or extensions involved in the call stack.

The full error and call stack looks like that:

a:5:{i:0;s:208:"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'main_table.status' in 'where clause', query was: SELECT COUNT(*) FROM `sales_flat_order_grid` AS `main_table` WHERE (`main_table.status` = 'processing')";i:1;s:5429:"#0 lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT COUNT(*)...', Array)
#4 lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SELECT COUNT(*)...', Array)
#5 lib/Zend/Db/Adapter/Abstract.php(828): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 lib/Varien/Data/Collection/Db.php(225): Zend_Db_Adapter_Abstract->fetchOne(Object(Varien_Db_Select), Array)
#7 lib/Varien/Data/Collection.php(225): Varien_Data_Collection_Db->getSize()
#8 lib/Varien/Data/Collection.php(211): Varien_Data_Collection->getLastPageNumber()
#9 lib/Varien/Data/Collection/Db.php(522): Varien_Data_Collection->getCurPage()
#10 lib/Varien/Data/Collection/Db.php(569): Varien_Data_Collection_Db->_renderLimit()
#11 app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(533): Varien_Data_Collection_Db->load()
#12 app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php(61): Mage_Adminhtml_Block_Widget_Grid->_prepareCollection()
#13 app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(626): Mage_Adminhtml_Block_Sales_Order_Grid->_prepareCollection()
#14 app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(632): Mage_Adminhtml_Block_Widget_Grid->_prepareGrid()
#15 app/code/core/Mage/Core/Block/Abstract.php(922): Mage_Adminhtml_Block_Widget_Grid->_beforeToHtml()
#16 app/code/core/Mage/Core/Block/Abstract.php(641): Mage_Core_Block_Abstract->toHtml()
#17 app/code/core/Mage/Core/Block/Abstract.php(585): Mage_Core_Block_Abstract->_getChildHtml('grid', true)
#18 app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php(77): Mage_Core_Block_Abstract->getChildHtml('grid')
#19 app/design/adminhtml/default/default/template/widget/grid/container.phtml(36): Mage_Adminhtml_Block_Widget_Grid_Container->getGridHtml()
#20 app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/...')
#21 app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#22 app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#23 app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#24 app/code/core/Mage/Adminhtml/Block/Widget/Container.php(308): Mage_Adminhtml_Block_Template->_toHtml()
#25 app/code/core/Mage/Core/Block/Abstract.php(923): Mage_Adminhtml_Block_Widget_Container->_toHtml()
#26 app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#27 app/code/core/Mage/Core/Block/Abstract.php(923): Mage_Core_Block_Text_List->_toHtml()
#28 app/code/core/Mage/Core/Block/Abstract.php(641): Mage_Core_Block_Abstract->toHtml()
#29 app/code/core/Mage/Core/Block/Abstract.php(585): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#30 app/design/adminhtml/default/default/template/page.phtml(74): Mage_Core_Block_Abstract->getChildHtml('content')
#31 app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/...')
#32 app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#33 app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#34 app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#35 app/code/core/Mage/Core/Block/Abstract.php(923): Mage_Adminhtml_Block_Template->_toHtml()
#36 app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#37 app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#38 app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(95): Mage_Core_Controller_Varien_Action->renderLayout()
#39 app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Sales_OrderController->indexAction()
#40 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#41 app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#42 app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#43 app/Mage.php(684): Mage_Core_Model_App->run(Array)
#44 index.php(87): Mage::run('', 'store')
#45 {main}";s:3:"url";s:41:"/index.php/admin/sales_order/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}

The issue is the new escaping of filter values as applied in Varien_Data_Collection_Db::_translateCondition. This leads to a SQL query like that:

SELECT COUNT(*) FROM sales_flat_order_grid AS main_table WHERE `main_table.status` = 'processing';

This cannot work since there is no column „main_table.status“. There is only a column „status“ of the table „main_table“.

The issue comes from an old version of the great extension Fooman_OrderManager. The issue has been fixed in versions greater or equal to 3.0.8. So if you encounter this issue, simply update the extension and everything works again.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert