inventory
inventory copied to clipboard
Cannot create a credit memo when product entity is deleted
Preconditions (*)
- Spotted on
2.4.4-p2
enterprise
Steps to reproduce (*)
-
cataloginventory/options/synchronize_with_catalog=0
(default this is the default value) - Create a sku with an inventory source
- Purchase the product
- invoice the order
- Delete the sku via the rest api
- See that the product is missing in
catalog_product_entity
- See that the product still exists inside
inventory_source_item
-
select * from inventory_source_item where sku not in (select sku from catalog_product_entity) and sku in (select sku from sales_order_item)
-
- See that the product is missing in
- In the admin panel go sales -> order, view your order, pick the invoice, click "credit memo" and see an error page and the following stack trace
[2023-03-03T14:15:41.489918+00:00] report.CRITICAL: TypeError: Magento\InventoryConfiguration\Model\IsSourceItemManagementAllowedForProductType\Interceptor::execute(): Argument #1 ($productType) must be of type string, null given, called in vendor/magento/module-inventory-sales/Model/GetProductSalableQty.php on line 108 and defined in generated/code/Magento/InventoryConfiguration/Model/IsSourceItemManagementAllowedForProductType/Interceptor.php:20
Stack trace:
#0 vendor/magento/module-inventory-sales/Model/GetProductSalableQty.php(108): Magento\InventoryConfiguration\Model\IsSourceItemManagementAllowedForProductType\Interceptor->execute()
#1 vendor/magento/module-inventory-sales/Model/GetProductSalableQty.php(75): Magento\InventorySales\Model\GetProductSalableQty->validateProductType()
#2 vendor/magento/module-inventory-sales-admin-ui/Model/GetSalableQuantityDataBySku.php(84): Magento\InventorySales\Model\GetProductSalableQty->execute()
#3 vendor/magento/module-inventory-sales-admin-ui/Model/GetIsManageStockForProduct.php(95): Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku->execute()
#4 vendor/magento/module-inventory-sales-admin-ui/Model/GetIsManageStockForProduct.php(66): Magento\InventorySalesAdminUi\Model\GetIsManageStockForProduct->getProductStockIds()
#5 vendor/magento/module-inventory-sales-admin-ui/Plugin/Sales/Block/Items/Renderer/DefaultRenderer/ChildManageStockIsOn.php(59): Magento\InventorySalesAdminUi\Model\GetIsManageStockForProduct->execute()
Because we have an inventory_source_item
but no product, we are doing a stock check and getting a PHP fatal error.
Expected result (*)
- I can create a credit memo
Actual result (*)
- I can not create a credit memo
Hi @convenient. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
Adding to this that this error is also thrown if the SKU of a product is changed, you don't even need to delete the product.
This suggests that the functionality should use the product ID which can't be changed (but could be deleted) rather than the SKU which can be changed or deleted.
Our workaround for this is that we have to update the SKU on the order to the new SKU for the SKU that is no longer in use and then process the credit memo. Not ideal.