elgentos / magento2-inventory-log

Magento 2 - Inventory Log
29 stars 11 forks source link

Handle credit memo items without a valid product in refund observer #11

Closed mfickers closed 8 months ago

mfickers commented 2 years ago

This fixes https://github.com/elgentos/magento2-inventory-log/issues/10

When a product is deleted after it has been ordered, the ProductRepository will throw an exception when trying to load the product for the credit memo item. Because this exception is never caught in the RefundOrderInventoryObserver, this results in a bug where you can't refund orders for products that have been deleted.

Catching the exception makes sure that the observer does not interfere with the refund process. Since there will be no stock for a credit memo item whose product has been deleted, we can just continue.

sprankhub commented 8 months ago

@peterjaap, this looks like a good thing to merge? Thanks!

peterjaap commented 8 months ago

@sprankhub totally! I completely missed this one. Sorry!