Custom Stock Handling Issue: The requested SKU is not assigned to the given stock
error for Product with 'Manage Stock = No'
#3407
Labels
Preconditions
2.4.2-p2
and2.4.7-beta2
Steps to reproduce
Expected result
Actual result
Exception #0 (Magento\InventoryConfigurationApi\Exception\SkuIsNotAssignedToStockException): The requested SKU is not assigned to the given stock.
Exception stacktrace
This issue seems to happen when the default stock is not the original Magento stock but a newly created stock set as default for the Main website.
Additional Information
Upon further investigation, it appears the issue may be related to the logic in
\Magento\InventoryConfiguration\Model\GetStockItemConfiguration::execute
, specifically line 71, where there's a check$this->defaultStockProvider->getId() !== $stockId
. Altering the return value in\Magento\InventoryCatalog\Model\DefaultStockProvider::getId
from1
to2
(the ID of the new default stock) seems to resolve the issue. However, it's unclear if this change might affect other areas of the system. This behavior suggests a potential oversight in handling custom default stocks when 'Manage Stock' is set to 'No'.The text was updated successfully, but these errors were encountered: