Skip to content

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

Open
@convenient

Description

@convenient

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions