magento / magento/inventory

Solve problem with \Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status\AdaptAddStockDataToCollectionPlugin

Open
#1,398 2 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

In Magento without MSI, when method \Magento\CatalogInventory\Model\ResourceModel\Stock\Status::addStockDataToCollection is called with $isFilterInStock = false, it is left joining
cataloginventory_stock_status table. Even if some product is absent in this table (e.g. Bundle product without any options), it is present in collection selection.

In Magento with MSI, plugin method \Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status\AdaptAddStockDataToCollectionPlugin::aroundAddStockDataToCollection is inner joining inventory_stock_X tables. So, if some product is absent in this table (e.g. Bundle product without any options), it will be absent in collection selection. But, if we will use left join, collection selection will contain all products, present in database.

This problem must be solved.

Also unskip test variation in \Magento\Bundle\Model\Product\FixedBundleWithSpecialPriceCalculatorTest::testPriceForFixedBundle.

Contributor guide

Open the contributing guide

Research direction

Start with Magento\InventoryCatalog\Plugin\CatalogInventory\Model\ResourceModel\Stock\Status\AdaptAddStockDataToCollectionPlugin::aroundAddStockDataToCollection and compare its join behavior with the described non-MSI method. Verify that using a left join retains products absent from inventory_stock_X tables, then unskip and run Magento\Bundle\Model\Product\FixedBundleWithSpecialPriceCalculatorTest::testPriceForFixedBundle.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, databases, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.