Skip to content

Magento 2.4.6-p2 ReservationData::__construct(): Argument #2 ($stock) must be of type int, null given – when redirecting to third party payment

I am getting the above error randomly when go to third-party payment pages, exactly on the redirection page.

This mainly occurs when a failed payment, and when we retry the checkout again.

As of now no certain pattern for this, and the cart is getting empty when this is happening.

Please advise.

[2023-10-29T13:53:37.538314+00:00] main.CRITICAL: MagentoFrameworkExceptionRuntimeException: Type Error occurred when creating object: MagentoInventoryIndexerModelQueueReservationData, MagentoInventoryIndexerModelQueueReservationData::__construct(): Argument #2 ($stock) must be of type int, null given, called in /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121 in /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:131
Stack trace:
#0 /var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): MagentoFrameworkObjectManagerFactoryAbstractFactory->createObject('Magento\Invento...', Array)
#1 /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php(56): MagentoFrameworkObjectManagerFactoryCompiled->create('Magento\Invento...', Array)
#2 /var/www/html/generated/code/Magento/InventoryIndexer/Model/Queue/ReservationDataFactory.php(43): MagentoFrameworkObjectManagerObjectManager->create('\Magento\Invent...', Array)
#3 /var/www/html/vendor/magento/module-inventory-indexer/Plugin/InventorySales/EnqueueAfterPlaceReservationsForSalesEvent.php(99): MagentoInventoryIndexerModelQueueReservationDataFactory->create(Array)
#4 /var/www/html/vendor/magento/module-inventory-indexer/Plugin/InventorySales/EnqueueAfterPlaceReservationsForSalesEvent.php(77): MagentoInventoryIndexerPluginInventorySalesEnqueueAfterPlaceReservationsForSalesEvent->getReservationsDataObject(Object(MagentoInventorySalesModelSalesChannel), Array)
#5 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(146): MagentoInventoryIndexerPluginInventorySalesEnqueueAfterPlaceReservationsForSalesEvent->afterExecute(Object(MagentoInventorySalesModelPlaceReservationsForSalesEventInterceptor), NULL, Array, Object(MagentoInventorySalesModelSalesChannel), Object(MagentoInventorySalesModelSalesEvent))
#6 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): MagentoInventorySalesModelPlaceReservationsForSalesEventInterceptor->MagentoFrameworkInterception{closure}(Array, Object(MagentoInventorySalesModelSalesChannel), Object(MagentoInventorySalesModelSalesEvent))
#7 /var/www/html/generated/code/Magento/InventorySales/Model/PlaceReservationsForSalesEvent/Interceptor.php(23): MagentoInventorySalesModelPlaceReservationsForSalesEventInterceptor->___callPlugins('execute', Array, Array)
#8 /var/www/html/vendor/magento/module-inventory-sales/Plugin/CatalogInventory/StockManagement/ProcessBackItemQtyPlugin.php(154): MagentoInventorySalesModelPlaceReservationsForSalesEventInterceptor->execute(Array, Object(MagentoInventorySalesModelSalesChannel), Object(MagentoInventorySalesModelSalesEvent))
#9 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): MagentoInventorySalesPluginCatalogInventoryStockManagementProcessBackItemQtyPlugin->aroundBackItemQty(Object(MagentoCatalogInventoryModelStockManagementInterceptor), Object(Closure), '2890', '1.0000', 'NULL')
#10 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): MagentoCatalogInventoryModelStockManagementInterceptor->MagentoFrameworkInterception{closure}('2890', '1.0000', 'NULL')
#11 /var/www/html/generated/code/Magento/CatalogInventory/Model/StockManagement/Interceptor.php(41): MagentoCatalogInventoryModelStockManagementInterceptor->___callPlugins('backItemQty', Array, NULL)
#12 /var/www/html/app/code/NetworkInternational/NGenius/Observer/ProductSaveAfter.php(90): MagentoCatalogInventoryModelStockManagementInterceptor->backItemQty('2890', '1.0000', 'NULL')
#13 /var/www/html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): NetworkInternationalNGeniusObserverProductSaveAfter->execute(Object(MagentoFrameworkEventObserver))
#14 /var/www/html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): MagentoFrameworkEventInvokerInvokerDefault->_callObserverMethod(Object(NetworkInternationalNGeniusObserverProductSaveAfter), Object(MagentoFrameworkEventObserver))
#15 /var/www/html/vendor/magento/framework/Event/Manager.php(65): MagentoFrameworkEventInvokerInvokerDefault->dispatch(Array, Object(MagentoFrameworkEventObserver))
#16 /var/www/html/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): MagentoFrameworkEventManager->dispatch('controller_acti...', Array)
#17 /var/www/html/vendor/magento/framework/App/FrontController.php(277): MagentoFrameworkEventManagerProxy->dispatch('controller_acti...', Array)
#18 /var/www/html/vendor/magento/framework/App/FrontController.php(211): MagentoFrameworkAppFrontController->dispatchPreDispatchEvents(Object(MagentoCheckoutControllerIndexIndexInterceptor), Object(MagentoFrameworkAppRequestHttp))
#19 /var/www/html/vendor/magento/framework/App/FrontController.php(146): MagentoFrameworkAppFrontController->processRequest(Object(MagentoFrameworkAppRequestHttp), Object(MagentoCheckoutControllerIndexIndexInterceptor))
#20 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#21 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#22 /var/www/html/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): MagentoStoreAppFrontControllerPluginRequestPreprocessor->aroundDispatch(Object(MagentoFrameworkAppFrontControllerInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#24 /var/www/html/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(75): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#25 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): MagentoPageCacheModelAppFrontControllerBuiltinPlugin->aroundDispatch(Object(MagentoFrameworkAppFrontControllerInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#26 /var/www/html/vendor/swissup/module-amp/Plugin/Framework/FrontController.php(48): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#27 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): SwissupAmpPluginFrameworkFrontController->aroundDispatch(Object(MagentoFrameworkAppFrontControllerInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
#29 /var/www/html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, NULL)
#30 /var/www/html/vendor/magento/framework/App/Http.php(116): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#31 /var/www/html/vendor/magento/framework/App/Bootstrap.php(264): MagentoFrameworkAppHttp->launch()
#32 /var/www/html/pub/index.php(30): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttpInterceptor))
#33 {main} {"report_id":"45cb9ca5f6f0d6e3a0e5b0ff226012e3a1a7d0ff19d984f14a85f0c493c6527f","exception":"[object] (Magento\Framework\Exception\RuntimeException(code: 0): Type Error occurred when creating object: Magento\InventoryIndexer\Model\Queue\ReservationData, Magento\InventoryIndexer\Model\Queue\ReservationData::__construct(): Argument #2 ($stock) must be of type int, null given, called in /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121 at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:131)"} []