SEP 16 2016

SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘`group`’ in ‘where clause’

Problem description

After SUPEE-6788 patch budnle or after upgrade to Magento 1.9.2.4 Ess/M2ePro extension is not updating products or cron execution results in SQL error like the following:

SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘`group`’ in ‘where clause’

a:5:{i:0;s:82:"SQLSTATE[42S22]: Column not found: 1054 Unknown column '`group`' in 'where clause'";i:1;s:2846:"#0 lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 lib/Zend/Db/Adapter/Abstract.php(479): 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(419): Zend_Db_Adapter_Pdo_Abstract->query('SELECT COUNT(*)...', Array)
#5 lib/Zend/Db/Adapter/Abstract.php(825): 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(653): Varien_Data_Collection_Db->getSize()
#8 app/code/community/Ess/M2ePro/Model/Config/Abstract.php(148): Varien_Data_Collection->toArray()
#9 app/code/community/Ess/M2ePro/Model/Config/Abstract.php(76): Ess_M2ePro_Model_Config_Abstract->setValue('/cron/task/proc...', 'start_from', '2016-09-15 02:2...')
#10 app/code/community/Ess/M2ePro/Model/Cron/Type/Service.php(114): Ess_M2ePro_Model_Config_Abstract->setGroupValue('/cron/task/proc...', 'start_from', '2016-09-15 02:2...')
#11 app/code/community/Ess/M2ePro/Model/Cron/Type/Service.php(49): Ess_M2ePro_Model_Cron_Type_Service->resetTaskStartFrom('processing')
#12 app/code/community/Ess/M2ePro/Model/Cron/Type/Service.php(77): Ess_M2ePro_Model_Cron_Type_Service->resetTasksStartFrom()
#13 app/code/community/Ess/M2ePro/Model/Cron/Type/Abstract.php(26): Ess_M2ePro_Model_Cron_Type_Service->initialize()
#14 app/code/community/Ess/M2ePro/controllers/CronController.php(32): Ess_M2ePro_Model_Cron_Type_Abstract->process()
#15 app/code/core/Mage/Core/Controller/Varien/Action.php(419): Ess_M2ePro_CronController->indexAction()
#16 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#17 app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#18 app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#19 app/Mage.php(683): Mage_Core_Model_App->run(Array)
#20 index.php(90): Mage::run('', 'store')
#21 {main}";s:3:"url";s:19:"/M2ePro/cron/index/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}

Cause

SUPEE-6788 patch bundle hardened requirements to SQL queries for third-party extensions and the extension is not properly updated to match all new requirements to Magento coding standards.

Solution

Update Ess/M2ePro extension to the latest version or change app/code/community/Ess/M2ePro/Model/Config/Abstract.php, app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Grid.php and app/code/community/Ess/M2ePro/Model/ConfigBase.php files as shown in the diff below:

--- app/code/community/Ess/M2ePro/Model/Config/Abstract.php
+++ app/code/community/Ess/M2ePro/Model/Config/Abstract.php
@@ -141,8 +141,8 @@
         if (is_null($group)) {
-            $temp->addFieldToFilter('`group`', array('null' => true));
+            $temp->addFieldToFilter('group', array('null' => true));
         } else {
-            $temp->addFieldToFilter('`group`', $group);
+            $temp->addFieldToFilter('group', $group);
         }
 
-        $temp->addFieldToFilter('`key`', $key);
+        $temp->addFieldToFilter('key', $key);
         $temp = $temp->toArray();
@@ -182,8 +182,8 @@
         if (is_null($group)) {
-            $temp->addFieldToFilter('`group`', array('null' => true));
+            $temp->addFieldToFilter('group', array('null' => true));
         } else {
-            $temp->addFieldToFilter('`group`', $group);
+            $temp->addFieldToFilter('group', $group);
         }
 
-        $temp->addFieldToFilter('`key`', $key);
+        $temp->addFieldToFilter('key', $key);
         $temp = $temp->toArray();
@@ -215,5 +215,5 @@
         if (is_null($group)) {
-            $temp->addFieldToFilter('`group`', array('null' => true));
+            $temp->addFieldToFilter('group', array('null' => true));
         } else {
-            $temp->addFieldToFilter('`group`', $group);
+            $temp->addFieldToFilter('group', $group);
         }
@@ -242,5 +242,5 @@
         if (is_null($group)) {
-            $temp->addFieldToFilter('`group`', array('null' => true));
+            $temp->addFieldToFilter('group', array('null' => true));
         } else {
-            $temp->addFieldToFilter('`group`', array("like"=>$group.'%'));
+            $temp->addFieldToFilter('group', array("like"=>$group.'%'));
         }
--- app/code/community/Ess/M2ePro/Model/ConfigBase.php
+++ app/code/community/Ess/M2ePro/Model/ConfigBase.php
@@ -76,3 +76,3 @@
         $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                           ->addFieldToFilter('`group`', array('null' => true))
+                                                           ->addFieldToFilter('group', array('null' => true))
                                                            ->toArray();
@@ -99,3 +99,3 @@
         $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                           ->addFieldToFilter('`group`', array('null' => true))
+                                                           ->addFieldToFilter('group', array('null' => true))
                                                            ->toArray();
@@ -129,3 +129,3 @@
         $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                           ->addFieldToFilter('`group`', array('null' => true))
+                                                           ->addFieldToFilter('group', array('null' => true))
                                                            ->toArray();
@@ -210,3 +210,3 @@
         $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                           ->addFieldToFilter('`group`', $group)
+                                                           ->addFieldToFilter('group', $group)
                                                            ->toArray();
@@ -241,3 +241,3 @@
         $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                           ->addFieldToFilter('`group`', $group)
+                                                           ->addFieldToFilter('group', $group)
                                                            ->toArray();
@@ -284,3 +284,3 @@
         $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                           ->addFieldToFilter('`group`', array("like"=>$group.'%'))
+                                                           ->addFieldToFilter('group', array("like"=>$group.'%'))
                                                            ->toArray();
@@ -352,4 +352,4 @@
             $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                               ->addFieldToFilter('`group`', (is_null($group)?array('null' => true):$group))
-                                                               ->addFieldToFilter('`key`', $key)
+                                                               ->addFieldToFilter('group', (is_null($group)?array('null' => true):$group))
+                                                               ->addFieldToFilter('key', $key)
                                                                ->toArray();
@@ -428,4 +428,4 @@
             $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                               ->addFieldToFilter('`group`', (is_null($group)?array('null' => true):$group))
-                                                               ->addFieldToFilter('`key`', $key)
+                                                               ->addFieldToFilter('group', (is_null($group)?array('null' => true):$group))
+                                                               ->addFieldToFilter('key', $key)
                                                                ->toArray();
@@ -456,4 +456,4 @@
             $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                               ->addFieldToFilter('`group`', (is_null($group)?array('null' => true):$group))
-                                                               ->addFieldToFilter('`key`', $key)
+                                                               ->addFieldToFilter('group', (is_null($group)?array('null' => true):$group))
+                                                               ->addFieldToFilter('key', $key)
                                                                ->toArray();
@@ -479,4 +479,4 @@
         $tempCollection = Mage::getModel($this->_ormConfig)->getCollection()
-                                                           ->addFieldToFilter('`group`', (is_null($group)?array('null' => true):$group))
-                                                           ->addFieldToFilter('`key`', $key)
+                                                           ->addFieldToFilter('group', (is_null($group)?array('null' => true):$group))
+                                                           ->addFieldToFilter('key', $key)
                                                            ->toArray();
--- app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Grid.php
+++ app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Template/NewProduct/Grid.php
@@ -51,3 +51,3 @@
         $collection = Mage::getModel('M2ePro/Amazon_Template_NewProduct')->getCollection();
-        $collection->addFieldToFilter('`marketplace_id`', $marketplaceId);
+        $collection->addFieldToFilter('marketplace_id', $marketplaceId);

Posted in: Fatal errors

SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘`group`’ in ‘where clause’
1 vote, 5.00 avg. rating (93% score)