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

Fix edge case canceling an order with a deleted product #118

Closed convenient closed 1 year ago

convenient commented 1 year ago

Prerequisites

To cover scenarios where the source items table is cleaned up upon delete, versus not

Fix an indexing issue when set to realtime (like when running the tests) and you delete a product, then cancel the order.

There were 2 errors:
1) Ampersand\DisableStockReservation\Test\Integration\Cancel\CancelOrderWithDeletedProduct::testCancelOrderWithDeletedProductAndNotSyncWithCatalog
Magento\Framework\Exception\InputException: Bad value was supplied.
/var/www/html/vendor/magento/module-catalog/Model/Indexer/Product/Price/Action/Rows.php:106
/var/www/html/vendor/magento/module-catalog/Model/Indexer/Product/Price.php:95
/var/www/html/vendor/magento/framework/Interception/Interceptor.php:58
/var/www/html/vendor/magento/framework/Interception/Interceptor.php:138
/var/www/html/vendor/magento/framework/Interception/Interceptor.php:153
/var/www/html/generated/code/Magento/Catalog/Model/Indexer/Product/Price/Interceptor.php:32
/var/www/html/vendor/magento/module-indexer/Model/Indexer.php:533
/var/www/html/vendor/magento/module-indexer/Model/Indexer/DependencyDecorator.php:294
/var/www/html/vendor/magento/framework/Indexer/AbstractProcessor.php:69
/current_extension/src/Service/ExecuteSourceDeductionForItems.php:172
/current_extension/src/Observer/CancelOrderItemObserver.php:55

Fix an issue where you cannot cancel an order, when you have deleted a product and also its source item, then cancel the order

2) Ampersand\DisableStockReservation\Test\Integration\Cancel\CancelOrderWithDeletedProduct::testCancelOrderWithDeletedProductAndSyncWithCatalog
Magento\Framework\Exception\NoSuchEntityException: Source item not found by source code: default and sku: product_will_be_deleted64b130378bd4d.
/var/www/html/vendor/magento/module-inventory-source-deduction-api/Model/GetSourceItemBySourceCodeAndSku.php:59
/current_extension/src/Model/SourceDeductionService/PatchedSourceDeductionService.php:82
/current_extension/src/Model/SourceDeductionService.php:30
/current_extension/src/Service/ExecuteSourceDeductionForItems.php:166
/current_extension/src/Observer/CancelOrderItemObserver.php:55
/var/www/html/vendor/magento/framework/Event/Invoker/InvokerDefault.php:88
/var/www/html/vendor/magento/framework/Event/Invoker/InvokerDefault.php:74
/var/www/html/vendor/magento/framework/Event/Manager.php:65
/var/www/html/generated/code/Magento/Framework/Event/Manager/Proxy.php:95
/var/www/html/vendor/magento/module-sales/Model/Order/Item.php:410
/var/www/html/vendor/magento/module-sales/Model/Order.php:1319
/var/www/html/vendor/magento/module-sales/Model/Order.php:1279
/current_extension/dev/MagentoTests/Integration/Cancel/CancelOrderWithDeletedProductTest.php:229

Checklist