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

Additional test cases for configurable/bundle products #33

Open nei opened 4 years ago

nei commented 4 years ago
convenient commented 4 years ago

https://github.com/magento/inventory/blob/50315c91617073d5d05f2503dbfd8d29cb93d9af/InventoryBundleProduct/etc/di.xml#L9-L11

I've seen on a magento slack channel that Bundle stock checks do not behave properly when done via API requests. This may be why we struggled to reproduce the issue from #17 in the test suite, which goes via the API

anuradha commented 3 years ago

Hi There,

In ampersand/magento2-disable-stock-reservation/src/Model/GetInventoryRequestFromOrder.php:87 uses the Magento\InventorySourceSelectionApi\Api\Data\InventoryRequestInterface and returns the StockId and Items.

$inventoryRequest = $this->inventoryRequestFactory->create([ 'stockId' => $stock->getStockId(), 'items' => $requestItems ]);

But this requestItems returns null.

Found the issue in ampersand/magento2-disable-stock-reservation/src/Model/GetSourceSelectionResultFromOrder.php#103

foreach ($orderItems as $orderItem) { if (!$this->isSourceItemManagementAllowedForProductType->execute($orderItem->getProductType())) { continue; }

When $orderItem->getProductType() is grouped,

if (!$this->isSourceItemManagementAllowedForProductType->execute($orderItem->getProductType())) { return false and unable to continue the checkout process. Getting the below error.

PHP Fatal error: Uncaught TypeError: Return value of Magento\InventorySourceSelection\Model\Request\InventoryRequest::getItems() must be of the type array, null returned in /www/vendor/magento/module-inventory-source-selection/Model/Request/InventoryRequest.php:102 Stack trace:

0 /www/vendor/magento/module-inventory-source-selection-api/Model/Algorithms/Result/GetDefaultSortedSourcesResult.php(97): Magento\InventorySourceSelection\Model\Request\InventoryRequest->getItems()

magento/magento2#1 /www/vendor/magento/module-inventory-source-selection/Model/Algorithms/PriorityBasedAlgorithm.php(73): Magento\InventorySourceSelectionApi\Model\Algorithms\Result\GetDefaultSortedSourcesResult->execute(Object(Magento\InventorySourceSelection\Model\Request\InventoryRequest), Array) magento/magento2#2 /www/vendor/magento/module-inventory-source-selection-api/Model/SourceSelectionService.php(61) in /www/vendor/magento/module-inventory-source-selection/Model/Request/InventoryRequest.php on line 102

Is there a fix for this? if not can you please check this issue? Appreciate an immediate response.

Thanks