Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create a credit memo when product entity is deleted #3376

Open
convenient opened this issue Mar 3, 2023 · 2 comments
Open

Cannot create a credit memo when product entity is deleted #3376

convenient opened this issue Mar 3, 2023 · 2 comments

Comments

@convenient
Copy link

Preconditions (*)

  1. Spotted on 2.4.4-p2 enterprise

Steps to reproduce (*)

  1. cataloginventory/options/synchronize_with_catalog=0 (default this is the default value)
  2. Create a sku with an inventory source
  3. Purchase the product
  4. invoice the order
  5. Delete the sku via the rest api
    1. See that the product is missing in catalog_product_entity
    2. See that the product still exists inside inventory_source_item
      1. select * from inventory_source_item where sku not in (select sku from catalog_product_entity) and sku in (select sku from sales_order_item)
  6. 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 (*)

  1. I can create a credit memo

Actual result (*)

  1. I can not create a credit memo
@m2-assistant
Copy link

m2-assistant bot commented Mar 3, 2023

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.

@davidgreenwooduktf
Copy link

davidgreenwooduktf commented Jun 20, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants