Closed caliboy007 closed 7 years ago
Solved: In regards to the attribute giving the error, I did not select the settings under 'Use in Product Listing' to 'Yes'. After I selected 'Yes' and did complete reindex the widget worked with the two conditions.
considering that it's possible to end up crashing any page when using that widget with certain attributes in the filter rules, I would recommend not closing this issue report.
Basically the catalog-widget expects all the attributes to be in the flat index, which is not the case with some of the default options it provides for the user to build a filter. There's logic in place there as well that will work when flat is disabled which should kick in for non-flat attributes. Currently it's pretty rough on making the decision without any exceptions. It's either everything flat or everything explicit join.
Here's one potential fix for that: https://github.com/allanpaiste/magento2-patches/blob/master/fix-crash-when-configuring-rules-for-non-flat-indexer-attributes.patch
Note that it's pretty dodgy as it does another DB request to get the info about the indexed attributes, but it does avoid the reported crash.
Environment
Steps to reproduce
Expected result
Actual result
Error filtering template: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.b_homepage' in 'where clause', query was:
SELECT COUNT(DISTINCT e.entity_id) FROM catalog_product_flat_1 AS e INNER JOIN catalog_category_product_index 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(e.entity_id, 0) IN (SELECT catalog_category_product.product_id FROM catalog_category_product WHERE (category_id IN ('42')))) AND(IFNULL(e.b_homepage, 0) = '1') ))
I have already performed the following tasks:
/vendor/magento/module-catalog-widget/Model/Rule/Condition/Combine.php /vendor/magento/module-catalog-widget/Model/Rule/Condition/Product.php /vendor/magento/module-catalog-widget/Test/Unit/Model/Rule/Condition/CombineTest.php