magento / inventory

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

Multi Source Inventory (MSI) with Custom Stock & Custom Sources Cause Products to Disappear #3332

Open uandiweb opened 2 years ago

uandiweb commented 2 years ago

Preconditions (*)

  1. Magento 2.4.3-p1
  2. Ensure "Display Out of Stock Products" is set to "No" (as per default Magento settings)
  3. Set products' visibility to "Catalog, Search"

Steps to reproduce (*)

  1. Create new inventory source (i.e. "Store 1")
  2. Create new inventory stock (i.e "Custom Stock")
  3. Set the "Main Website" to be a sales channel of the "Custom Stcok"
  4. Assign "Store 1" to be a source of "Custom Stock
  5. Unassign the "Default" inventory source from all products
  6. Assign the new inventory source "Store 1" to all products
  7. Add quantity to products ("Store 1") & mark those products as "In stock"
  8. Reindex the website & clear the cache

Expected result (*)

  1. Products with positive "salable quantity" should show in category pages
  2. Products with positive "salable quantity" should show in search

Actual result (*)

  1. Products with positive "salable quantity" don't show in category pages
  2. Products with positive "salable quantity" don't show in search

Please note: When "Display Out of Stock Products" is set to "Yes" then products with positive "salable quantity" do show in category pages & search. However, I don't want to show out of stock products so this is not a good solution.

Below you can see my custom stock setup:

custom_stock_settings

m2-assistant[bot] commented 2 years ago

Hi @uandiweb. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


nthurston commented 2 years ago

Do you happen to have gaps in your entity ids?

I just came here to report something similar to https://github.com/magento/magento2/issues/31224

Which is now happening specifically with MSI because of the plugin in module-inventory-catalog-search/Plugin/CatalogSearch/Model/Indexer/ChildProductFilterByInventoryStockPlugin.php

FYI it works when Show out of stock is set to yes because it checks that and returns without running the filter in the plugin:

if ($this->stockConfiguration->isShowOutOfStock($storeId) || empty($result)) {
    return $result;
}
return $this->filterProductByStock->execute($result, (int)$storeId);