magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Widget Catalog Product List query is false #6027

Closed vocongdanh closed 7 years ago

vocongdanh commented 8 years ago

Preconditions

  1. Magento 2.1
  2. PHP version 5.6.x

    Steps to reproduce

  1. Create a widget Catalog Product List, set condition category is 3
  2. Save and Flush Cache
  3. Run, and print sql query

    Expected result

  1. SELECT e.*, cat_index.position AS cat_index_position, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price FROM catalog_product_entity 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='3' 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 ('3')))) ))
  2. cat_index.category_id='3' is true.

    Actual result

  1. SELECT e.*, cat_index.position AS cat_index_position, price_index.price, price_index.tax_class_id, price_index.final_price, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS minimal_price, price_index.min_price, price_index.max_price, price_index.tier_price FROM catalog_product_entity 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 ('3')))) ))
  2. cat_index.category_id='2' is false, it must is 3. if you create a extension override this block and add 1 order as order by cat_index.position ASC, it won't work expect.

Sorry my english is not good.

designbyadrian commented 8 years ago

I had the same issue. Are your cron jobs running? Try forcing a re-index of your site:

php bin/magento indexer:reindex

slopukhov commented 8 years ago

@vocongdanh thank you for your feedback, Please, recheck it on the latest 2.1 version of Magento with configured cron job.

veloraven commented 7 years ago

According to contributor guide, tickets without response for two weeks should be closed. If this issue still reproducible please feel free to create the new one: format new issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result and specify Magento version.