Code Monkey home page Code Monkey logo

Comments (5)

SamJUK avatar SamJUK commented on August 26, 2024

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)
         ];
     }

from adyen-magento2.

RokPopov avatar RokPopov commented on August 26, 2024

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 -> 'id' => $product->getId(),, wouldn't it be necessary to change the way this ID is being fetched?

Kind regards,
Rok

from adyen-magento2.

SamJUK avatar SamJUK commented on August 26, 2024

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 id and productUrl in the return array with the variables defined above.

Thanks
Sam

from adyen-magento2.

RokPopov avatar RokPopov commented on August 26, 2024

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,
Rok

from adyen-magento2.

SamJUK avatar SamJUK commented on August 26, 2024

@RokPopov Sure thing, opened a PR with ID #2645

from adyen-magento2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.