magento-lts: Product flat tables broken, ref #2603
Preconditions (*)
- 19.4.x-latest
- Sample Data installed
- Flat product tables ON
Steps to reproduce (*)
Actual result (*)
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1=1 AND ( e.website_id = '1' ) AND ( e.customer_group_id = 0) AND (e.min_pric...' at line 2, query was: SELECT FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 AS `range`, COUNT(*) AS `count` FROM `catalog_product_index_price` AS `e`
 INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=3 AND cat_index.visibility IN(2, 4) AND cat_index.category_id = '14' WHERE 1=1 1=1 AND ( e.website_id = '1' ) AND ( e.customer_group_id = 0) AND (e.min_price IS NOT NULL) GROUP BY FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 ORDER BY FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 ASC
#0 /var/www/html/lib/Varien/Db/Statement/Pdo/Mysql.php(104): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/html/app/code/core/Zend/Db/Statement.php(289): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /var/www/html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT FLOOR((R...', Array)
#4 /var/www/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(502): Zend_Db_Adapter_Pdo_Abstract->query('SELECT FLOOR((R...', Array)
#5 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(811): Varien_Db_Adapter_Pdo_Mysql->query('SELECT FLOOR((R...', Array)
#6 /var/www/html/app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php(272): Zend_Db_Adapter_Abstract->fetchPairs(Object(Varien_Db_Select))
#7 /var/www/html/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php(152): Mage_Catalog_Model_Resource_Layer_Filter_Price->getCount(Object(Mage_Catalog_Model_Layer_Filter_Price), 100)
See  WHERE 1=1 1=1 … related code … Mage_Catalog_Model_Resource_Layer_Filter_Price::_getSelect()
        // processing WHERE part
        $wherePart = $select->getPart(Zend_Db_Select::WHERE);
        $excludedWherePart = Mage_Catalog_Model_Resource_Product_Collection::MAIN_TABLE_ALIAS . '.status';
        foreach ($wherePart as $key => $wherePartItem) {
            if (strpos($wherePartItem, $excludedWherePart) !== false) {
                $wherePart[$key] = new Zend_Db_Expr('1=1');
                continue;
            }
            $wherePart[$key] = $this->_replaceTableAlias($wherePartItem);
        }
Before #2603
" FROM `catalog_product_index_price` AS `e`
 INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=3 AND cat_index.visibility IN(2, 4) AND cat_index.category_id = '14' WHERE 1=1 AND ( e.website_id = '1' ) AND ( e.customer_group_id = 0) AND (e.min_price IS NOT NULL)"
$wherePart = {object[1]} 
 0 = {Zend_Db_Expr} "1=1"
$wherePartItem = "(e.status = 1)"
After:
" FROM `catalog_product_index_price` AS `e`
 INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=3 AND cat_index.visibility IN(2, 4) AND cat_index.category_id = '14' WHERE 1=1 1=1 AND ( e.website_id = '1' ) AND ( e.customer_group_id = 0) AND (e.min_price IS NOT NULL)"
$wherePart = {object[2]} 
 0 = {Zend_Db_Expr} "1=1"
 1 = {Zend_Db_Expr} "1=1"
$wherePart = {string[2]} ["(e.status = 1)", "AND (e.status I..."]
 0 = "(e.status = 1)"
 1 = "AND (e.status IN(1))"
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 40 (39 by maintainers)
Anyway it’s 1.30AM so I’ll pass