elgentos / magento2-inventory-log

Magento 2 - Inventory Log
29 stars 11 forks source link

Error when refunding an order where a product has been deleted #10

Closed mfickers closed 8 months ago

mfickers commented 2 years ago

Title

The \Elgentos\InventoryLog\Observer\RefundOrderInventoryObserver tries to load the product for every creditmemo item. If the product has been deleted, the ProductRepository will throw an exception, that is not caught in the observer. This results in an error where you can't refund this order.

Preconditions

Tested on Magento 2.4.2-p1 with version 1.1.4 of this extension

Steps to reproduce

  1. Create an order
  2. Create the invoice for the order
  3. Delete a product of this order
  4. Create a credit memo for the invoice, refunding the order

Expected result

  1. The credit memo is created
  2. The order is refunded

Actual result

  1. The credit memo does not get created
  2. The order is not refunded
  3. Error message: "The product that was requested doesn't exist. Verify the product and try again."