-
Notifications
You must be signed in to change notification settings - Fork 212
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
[ECP-9246] Unable to create Credit Memos for orders containing deleted products. #2636
Comments
We are running the following composer patch in production now, and thats allowing Credit Memos to be processed successfully now. --- Helper/OpenInvoice.php
+++ Helper/OpenInvoice.php
@@ -127,7 +127,7 @@
$product = $item->getProduct();
$imageUrl = "";
- if ($image = $product->getSmallImage()) {
+ if ($product && $image = $product->getSmallImage()) {
$imageUrl = $this->imageHelper->init($product, 'product_page_image_small')
->setImageFile($image)
->getUrl();
@@ -185,16 +185,18 @@
$formattedTaxPercentage = $this->adyenHelper->formatAmount($item->getTaxPercent(), $currency);
$product = $item->getProduct();
+ $productId = $product ? $product->getId() : $item->getProductId();
+ $productUrl = $product ? $product->getUrlModel()->getUrl($product) : '';
return [
- 'id' => $product->getId(),
+ 'id' => $productId,
'amountExcludingTax' => $formattedPriceExcludingTax,
'amountIncludingTax' => $formattedPriceIncludingTax,
'taxAmount' => $formattedTaxAmount,
'description' => $item->getName(),
'quantity' => (int) ($qty ?? $item->getQty()),
'taxPercentage' => $formattedTaxPercentage,
- 'productUrl' => $product->getUrlModel()->getUrl($product),
+ 'productUrl' => $productUrl,
'imageUrl' => $this->getImageUrl($item)
];
} |
Hi @SamJUK, Thank you for reporting this issue and sharing the patch with us. We have opened an internal investigation to find alternative ways of finding the ID to be used to populate the line items. Checking your patch, with regards to the error being thrown in this line -> Kind regards, |
Hi @RokPopov , Yes your correct, I uploaded an incomplete version of the patch. I've updated it now to the full version, essentially just replacing both Thanks |
Hi @SamJUK, Thank you for adjusting the patch, much appreciated. Would you be willing to create a PR with the changes in the patch? Kind regards, |
Describe the bug
Unable to create a credit memo for orders containing deleted products.
Getting the following Error message
An error has happened during application run. See exception log for details.
With the following log message
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Credit memo to create successfully.
Magento version
2.4.5-p7
Plugin version
9.5.2
Additional Information
It should be expected that calling
getProduct
on a order item could return null, in the case the original product no longer exists in the catalog. Either should be looking to use the data baked into the line item, or have logic to handle cases where the original item no longer exists.The text was updated successfully, but these errors were encountered: