AmpersandHQ / magento2-disable-stock-reservation

This module disables the inventory reservation logic introduced as part of MSI in Magento 2.3.3
GNU Lesser General Public License v3.0
215 stars 61 forks source link

Configurable products not deducting stock properly #57

Open BrentRobert opened 2 years ago

BrentRobert commented 2 years ago

The change underneath resulted in the creation of multiple itemRequests for configurableProducts. https://github.com/AmpersandHQ/magento2-disable-stock-reservation/commit/5e46cef6788996b7bc30a4bfaa805de1481fcb38

When ordering a configurable product, a row is created for the simple and the configurable. However Magento uses the SKU of the simple for both on the order item. The mapping that was created above results in allowing configurable order items to be deducted on the SKU of the simple.

The reason this has been unnoticed is because the itemRequests are not grouped as in 'GetItemsToDeductFromOrder'. Magento loops over these requests and overwrites SKU based in the array. Always using the latest value. In this case the simple.

foreach ($inventoryRequest->getItems() as $item) {
    $normalizedSku = $this->normalizeSku($item->getSku());
    $itemsTdDeliver[$normalizedSku] = $item->getQty();
}

TLDR;

convenient commented 2 years ago

Thanks for your issue @BrentRobert If you have a PR to go with it that would be very much appreciated 👍

BrentRobert commented 2 years ago

@convenient might you be able to add a test for grouped & configurable products?

tr33m4n commented 6 months ago

Hi @BrentRobert, is this issue now resolved? You had a PR into the module but it's since been closed. Thanks

BrentRobert commented 6 months ago

@tr33m4n I honestly have no idea. I closed the PR as it had been open for 2 years.