Question

When I am changed setting for Flat Catalog Product to Yes, it gives SQL error in magento 2.

Stores >> Configuration >> Catalog >> Catalog

Is this known bug in magento 2.2.6?

I have done re-indexing after setting changed to Yes.

Please provide the guidance on this.

SQL Error as below:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'at_featured.value' in 'where clause', query was: 

SELECT DISTINCT  COUNT(DISTINCT e.entity_id) FROM `catalog_product_flat_1` AS `e`
INNER JOIN `catalog_category_product_index_store1` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND 
cat_index.visibility IN(2, 4) AND cat_index.category_id='2'
INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND 
price_index.customer_group_id = 0 WHERE (((IFNULL(`at_featured`.`value`, 0) = '1') ))

enter image description here

Was it helpful?

Solution

You have to rebuild the index. Afterwards it should work.

The reason is that your attribute "featured" has been added after the flat index has been rebuilt the last time.

The flat index works by creating a column for each attribute that is used in the product listing. The error says that the column is missing, so you have to rebuild the index.

Extensions or custom codes can also mess around with this. If the error persists after the index has been rebuilt, make sure that "Use in product listing" is set to "Yes" for that attribute, rebuild the index again and try to load the page again.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top