Open nei opened 4 years ago
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
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