magento / inventory

Magento Inventory Project (a.k.a MSI)
Open Software License 3.0
337 stars 247 forks source link

fix(inventory-catalog): don't join disabled products into collection #3401

Open damienwebdev opened 11 months ago

damienwebdev commented 11 months ago

Description (*)

MSI mistakenly conflates two situations as the same as a result of complex indexing behaviors.

  1. When a product is disabled, it has no entry in the cataloginventory_stock_index or inventory_stock_*
  2. When a product is not assigned to any sources, it has no entry in the cataloginventory_stock_index or inventory_stock_*

Fixed Issues (if relevant)

Currently, when computing the children of composite products like Bundles, Groups and Configurables, MSI will accidentally join in disabled children resulting in records with is_salable = NULL when adding stock data to a product collection.

This commit restores the original behavior.

This problem comes from @bubasuma in two separate commits

The commit https://github.com/magento/inventory/commit/e8d2ca76fc43101afd734d3f58357f1918cf1971 attempts to allow products on category pages when the stock has no sources.

The second https://github.com/magento/inventory/commit/17cf3428a3e0de1237530305be4986b89fb83b70 attempts to allow computing the lowest price of a configurable using only in stock products.

I'm specifically reverting part of https://github.com/magento/inventory/commit/17cf3428a3e0de1237530305be4986b89fb83b70 but https://github.com/magento/inventory/commit/e8d2ca76fc43101afd734d3f58357f1918cf1971 is also mistaken.

Likely, both of these commits need to be reverted and reworked to disambiguate "not in the stock index" from:

  1. When a product is disabled
  2. When a product is not assigned to any sources

Contribution checklist (*)

paresh6002 commented 9 months ago

@magento run all tests

magento-automated-testing[bot] commented 9 months ago

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.