magento2: "Sort By: Price" issues with Configurable Products does not work without forced reindex

Preconditions

Verified with 2 clean installations (no 3rd party modules)

  • Magento 2.3.1 CE
  • ElasticSearch 5.6.14
  • Production Mode
  • Index on Schedule

And:

  • Magento 2.2.6 CE
  • ElasticSearch 5.6.14
  • Production Mode
  • Index on Schedule

Steps to reproduce

  1. Install clean Magento 2 instance
  2. Deploy Sample Data
  3. Run setup:upgrade (to install sample data)
  4. Enter any category, choose “Price” as a “Sort By”

Expected Result

  1. Products are displayed from the cheapest to the most expensive image

Actual Result

  1. Getting products with prices: 29.00, 22.00, 28.00, 24.00 image

Notice that also star rating is missing before manual reindex.

Under the hood, the difference is quite big:

image

Before: BEFORE_result.json.txt

After AFTER_result.json.txt

Workaround

Run bin/magento index:reindex until products are in the right order (sometimes more than once)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 31 (21 by maintainers)

Commits related to this issue

Most upvoted comments

@chdzma

I found a solution in this file.

/vendor/magento/module-configurable-product/Model/ResourceModel/Product/Indexer/Price/Configurable.php

I commented out this section in the function fillTemporaryOptionsTable

// Does not make sense to extend query if out of stock products won't appear in tables for indexing

/*if ($this->isConfigShowOutOfStock()) {
   $select->join(
      ['si' => $this->getTable('cataloginventory_stock_item')],
      'si.product_id = l.product_id',
      []
   );
   $select->where('si.is_in_stock = ?', Stock::STOCK_IN_STOCK);
}*/

And now it works correctly, it’s absurd because every product is in the same condition, enabled, and out of stock.

I commented directly in the core, since I’m really sick of working on Magento2 and I want to close this project as soon as possibile. When I finish this my agency will abandon the platform for something else.

Last week I wasted three days of work for not-working shipping e-mail. I’m really annoyed.

This issue should be reopened as well!

Hi @lbajsarowicz, @ilnytskyi, @engcom-Delta.

Thank you for your report and collaboration!

The related internal Jira ticket MC-23835 was closed as non-reproducible in 2.4-develop. It means that Magento team either unable to reproduce this issue using provided Steps to Reproduce from the Description section on clean Magento instance or the issue has been already fixed in the scope of other tasks.

But if you still run into this problem please update or provide additional information/steps/preconditions in the Description section and reopen this issue.