0

I am facing an issue after re-indexing not able to add or edit product and old products are not showing.

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 ') ) ) AND (p.entity_id = '2112') LIMIT 1' at line 3, query was: SELECT DISTINCT p.entity_id FROM catalog_product_entity AS p INNER JOIN catalog_product_flat_1 AS cpf ON cpf.entity_id = p.entity_id LEFT JOIN catalog_category_product AS ccp ON ccp.product_id = p.entity_id WHERE ( ( (cpf.attribute_set_id='4' AND ) ) ) AND (p.entity_id = '2112') LIMIT 1

AND is 2 times, but it comes from magento core before when i didn't do re-indexing i can do edit and update there is no SQL error but after re-indexing its appears.

I Checked all the necessary things like (Status,Visibility,Qty ,Stock Availability,Product Categories,Indexes and Caches), but i am not able to add or even edit old products, or not able to view on fronted any product on detail page..

app\code\core\Mage\Rule\Model\Resource\Abstract.php

public function getProductFlatSelect($storeId, $condition)
{
    $select = $this->_getReadAdapter()->select();
    $select->from(
            array('p' => $this->getTable('catalog/product')),
            array(new Zend_Db_Expr('DISTINCT p.entity_id'))
        )
        ->joinInner(
            array('cpf' => $this->getTable('catalog/product_flat') . '_' . $storeId),
            'cpf.entity_id = p.entity_id',
            array()
        )->joinLeft(
            array('ccp' => $this->getTable('catalog/category_product')),
            'ccp.product_id = p.entity_id',
            array()
        );

    $where = $condition->prepareConditionSql();
    if (!empty($where)) {
        $select->where($where);
    }

    return $select;
}
Savan Patel
  • 2,348
  • 1
  • 16
  • 39

1 Answers1

1

The query has the syntax error because some of the catalog rule conditions are incomplete: https://prnt.sc/xnf5zo When the flat catalog is enabled the query checks also the catalog rules. You should check all your rules and edit the conditions to solve the issue.