Published: February 1, 2016
Last updated:

Magestore Bannerslider not shown after SUPEE-6788 or Magento upgrade

Problem description

After SUPEE-6788 patch budnle or after upgrade to Magento 1.9.2.4 Magestore Bannerslider sliders are not shown, hidden or page with sliders or results in SQL error like the following:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘.`value)` = ‘0’) AND (`start_time`
a:5:{i:0;s:643:"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`value)` = '0') AND (`start_time` = '2016-01-' at line 2, query was: SELECT `main_table`.* FROM `bannerslider_banner` AS `main_table`
 LEFT JOIN `bannerslider_value` AS `status` ON main_table.banner_id = status.banner_id AND status.store_id = 1 AND status.attribute_code = 'status' WHERE (`bannerslider_id` = '2') AND (`IF(status`.`value IS NULL, main_table`.`status, status`.`value)` = '0') AND (`start_time` = '2016-01-28') ORDER BY order_banner ASC";i:1;s:4886:"#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 `main_ta...', Array)
#4 lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `main_ta...', Array)
#5 lib/Zend/Db/Adapter/Abstract.php(737): Varien_Db_Adapter_Pdo_Mysql->query('SELECT `main_ta...', Array)
#6 lib/Varien/Data/Collection/Db.php(740): Zend_Db_Adapter_Abstract->fetchAll('SELECT `main_ta...', Array)
#7 app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(521): Varien_Data_Collection_Db->_fetchAll('SELECT `main_ta...', Array)
#8 lib/Varien/Data/Collection/Db.php(572): Mage_Core_Model_Resource_Db_Collection_Abstract->getData()
#9 lib/Varien/Data/Collection.php(741): Varien_Data_Collection_Db->load()
#10 app/code/community/Magestore/Bannerslider/Block/Default.php(44): Varien_Data_Collection->getIterator()

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

Make sure that bannerslider/default block is whitelisted at CMS > Pages or CMS > Static Blocks, you can refer to this article for detailed instructions on whitelisting blocks. To solve SQL error change line 60 in app/code/community/Magestore/Bannerslider/Model/Mysql4/Banner/Collection.php as shown in the diff below:
--- Bannerslider/Model/Mysql4/Banner/Collection.php
+++ Bannerslider/Model/Mysql4/Banner/Collection.php
@@ -59,3 +59,3 @@
             }
-            return parent::addFieldToFilter("IF($field.value IS NULL, main_table.$field, $field.value)", $condition);
+           $this->getSelect()->where("IF($field.value IS NULL, main_table.$field, $field.value) = 0");
         }

Posted in: Fatal errors

61 votes, 4.53 avg. rating (90% score)