How to get the product image in invoice email template? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Different Invoice/Order Emails for same Transactional Email templateUncaught Error: Call to a member function setItem() on boolean on product grid: Magento 2Bundle product email templateMagento 2 - Order email - template override not workingsend invoice email proagramtically magento2(Solved) Magento 2, Add product image in all transaction emails(shipment, invoice, credit memo)Magento2 - Override Template order summary in sales email orderMagento 2 - How to add product image in order confirmation email ( without object manager )?Get product image for invoice email in magento 2.3

Recursive calls to a function - why is the address of the parameter passed to it lowering with each call?

Protagonist's race is hidden - should I reveal it?

Does GDPR cover the collection of data by websites that crawl the web and resell user data

Should man-made satellites feature an intelligent inverted "cow catcher"?

How to leave only the following strings?

Who can become a wight?

What helicopter has the most rotor blades?

What's the difference between using dependency injection with a container and using a service locator?

Why aren't these two solutions equivalent? Combinatorics problem

When does Bran Stark remember Jamie pushing him?

Unix AIX passing variable and arguments to expect and spawn

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

How do I overlay a PNG over two videos (one video overlays another) in one command using FFmpeg?

How to mute a string and play another at the same time

Assertions In A Mock Callout Test

Lights are flickering on and off after accidentally bumping into light switch

Network questions

Reflections in a Square

Can 'non' with gerundive mean both lack of obligation and negative obligation?

Who's this lady in the war room?

How do I deal with an erroneously large refund?

What is the definining line between a helicopter and a drone a person can ride in?

Coin Game with infinite paradox

How to create a command for the "strange m" symbol in latex?



How to get the product image in invoice email template?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Different Invoice/Order Emails for same Transactional Email templateUncaught Error: Call to a member function setItem() on boolean on product grid: Magento 2Bundle product email templateMagento 2 - Order email - template override not workingsend invoice email proagramtically magento2(Solved) Magento 2, Add product image in all transaction emails(shipment, invoice, credit memo)Magento2 - Override Template order summary in sales email orderMagento 2 - How to add product image in order confirmation email ( without object manager )?Get product image for invoice email in magento 2.3



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have succeeded in getting the product image in the new order email template (<Vendor>/<Theme>/Magento_Sales/templates/email/items/order/default.phtml) using the following:



<img src="<?= $this->helper('MagentoCatalogHelperImage')
->init($_item->getProduct(), 'product_thumbnail_image')
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepTransparency(TRUE)
->keepFrame(FALSE)
->resize(200, 260)->getUrl(); ?>" alt="<?= $block->escapeHtml($_item->getName()) ?>" width="100">


But whenever I try the same code in the invoice template (<Vendor>/<Theme>/Magento_Sales/templates/email/items/invoice/default.phtml) I receive the following error:



PHP Fatal error: Uncaught Error: Call to a member function getData() on null in /var/www/public/vendor/magento/module-catalog/Helper/Image.php:500
Stack trace:
#0 /var/www/public/vendor/magento/module-catalog/Helper/Image.php(470): Magento\Catalog\Helper\Image->initBaseFile()
#1 /var/www/public/vendor/magento/module-catalog/Helper/Image.php(528): Magento\Catalog\Helper\Image->applyScheduledActions()
#2 /var/www/public/app/design/frontend/Falak/englishfalak/Magento_Sales/templates/email/items/invoice/default.phtml(30): Magento\Catalog\Helper\Image->getUrl()
#3 /var/www/public/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/public...')
#4 /var/www/public/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Sales\Block\Order\Email\Items\DefaultItems\Interceptor), '/var/www/public...', Array)
#5 /var/www/public/generated/code/Magento/Sales/Block/Order/Email/Items/DefaultItems/Interceptor.php(180): Magento\Framework\View\Element\Templa in /var/www/public/vendor/magento/module-catalog/Helper/Image.php on line 500, referer: http://lifestyley.localhost/admin/sales/invoice/view/order_id/123/invoice_id/4/key/ca0c7bf344bba27a0ed4dc1353f1f81c98c4c30764c9640ff79dd10108313c75/


Why it's not working in the invoice template but working on the order template?



The variable $_item is there in both of them and is retrieved in the same way in both cases. And in both files, I'm using several functions on this variable successfully. The only problem seems when I try to retrieve the products pictures.










share|improve this question




























    0















    I have succeeded in getting the product image in the new order email template (<Vendor>/<Theme>/Magento_Sales/templates/email/items/order/default.phtml) using the following:



    <img src="<?= $this->helper('MagentoCatalogHelperImage')
    ->init($_item->getProduct(), 'product_thumbnail_image')
    ->constrainOnly(TRUE)
    ->keepAspectRatio(TRUE)
    ->keepTransparency(TRUE)
    ->keepFrame(FALSE)
    ->resize(200, 260)->getUrl(); ?>" alt="<?= $block->escapeHtml($_item->getName()) ?>" width="100">


    But whenever I try the same code in the invoice template (<Vendor>/<Theme>/Magento_Sales/templates/email/items/invoice/default.phtml) I receive the following error:



    PHP Fatal error: Uncaught Error: Call to a member function getData() on null in /var/www/public/vendor/magento/module-catalog/Helper/Image.php:500
    Stack trace:
    #0 /var/www/public/vendor/magento/module-catalog/Helper/Image.php(470): Magento\Catalog\Helper\Image->initBaseFile()
    #1 /var/www/public/vendor/magento/module-catalog/Helper/Image.php(528): Magento\Catalog\Helper\Image->applyScheduledActions()
    #2 /var/www/public/app/design/frontend/Falak/englishfalak/Magento_Sales/templates/email/items/invoice/default.phtml(30): Magento\Catalog\Helper\Image->getUrl()
    #3 /var/www/public/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/public...')
    #4 /var/www/public/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Sales\Block\Order\Email\Items\DefaultItems\Interceptor), '/var/www/public...', Array)
    #5 /var/www/public/generated/code/Magento/Sales/Block/Order/Email/Items/DefaultItems/Interceptor.php(180): Magento\Framework\View\Element\Templa in /var/www/public/vendor/magento/module-catalog/Helper/Image.php on line 500, referer: http://lifestyley.localhost/admin/sales/invoice/view/order_id/123/invoice_id/4/key/ca0c7bf344bba27a0ed4dc1353f1f81c98c4c30764c9640ff79dd10108313c75/


    Why it's not working in the invoice template but working on the order template?



    The variable $_item is there in both of them and is retrieved in the same way in both cases. And in both files, I'm using several functions on this variable successfully. The only problem seems when I try to retrieve the products pictures.










    share|improve this question
























      0












      0








      0








      I have succeeded in getting the product image in the new order email template (<Vendor>/<Theme>/Magento_Sales/templates/email/items/order/default.phtml) using the following:



      <img src="<?= $this->helper('MagentoCatalogHelperImage')
      ->init($_item->getProduct(), 'product_thumbnail_image')
      ->constrainOnly(TRUE)
      ->keepAspectRatio(TRUE)
      ->keepTransparency(TRUE)
      ->keepFrame(FALSE)
      ->resize(200, 260)->getUrl(); ?>" alt="<?= $block->escapeHtml($_item->getName()) ?>" width="100">


      But whenever I try the same code in the invoice template (<Vendor>/<Theme>/Magento_Sales/templates/email/items/invoice/default.phtml) I receive the following error:



      PHP Fatal error: Uncaught Error: Call to a member function getData() on null in /var/www/public/vendor/magento/module-catalog/Helper/Image.php:500
      Stack trace:
      #0 /var/www/public/vendor/magento/module-catalog/Helper/Image.php(470): Magento\Catalog\Helper\Image->initBaseFile()
      #1 /var/www/public/vendor/magento/module-catalog/Helper/Image.php(528): Magento\Catalog\Helper\Image->applyScheduledActions()
      #2 /var/www/public/app/design/frontend/Falak/englishfalak/Magento_Sales/templates/email/items/invoice/default.phtml(30): Magento\Catalog\Helper\Image->getUrl()
      #3 /var/www/public/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/public...')
      #4 /var/www/public/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Sales\Block\Order\Email\Items\DefaultItems\Interceptor), '/var/www/public...', Array)
      #5 /var/www/public/generated/code/Magento/Sales/Block/Order/Email/Items/DefaultItems/Interceptor.php(180): Magento\Framework\View\Element\Templa in /var/www/public/vendor/magento/module-catalog/Helper/Image.php on line 500, referer: http://lifestyley.localhost/admin/sales/invoice/view/order_id/123/invoice_id/4/key/ca0c7bf344bba27a0ed4dc1353f1f81c98c4c30764c9640ff79dd10108313c75/


      Why it's not working in the invoice template but working on the order template?



      The variable $_item is there in both of them and is retrieved in the same way in both cases. And in both files, I'm using several functions on this variable successfully. The only problem seems when I try to retrieve the products pictures.










      share|improve this question














      I have succeeded in getting the product image in the new order email template (<Vendor>/<Theme>/Magento_Sales/templates/email/items/order/default.phtml) using the following:



      <img src="<?= $this->helper('MagentoCatalogHelperImage')
      ->init($_item->getProduct(), 'product_thumbnail_image')
      ->constrainOnly(TRUE)
      ->keepAspectRatio(TRUE)
      ->keepTransparency(TRUE)
      ->keepFrame(FALSE)
      ->resize(200, 260)->getUrl(); ?>" alt="<?= $block->escapeHtml($_item->getName()) ?>" width="100">


      But whenever I try the same code in the invoice template (<Vendor>/<Theme>/Magento_Sales/templates/email/items/invoice/default.phtml) I receive the following error:



      PHP Fatal error: Uncaught Error: Call to a member function getData() on null in /var/www/public/vendor/magento/module-catalog/Helper/Image.php:500
      Stack trace:
      #0 /var/www/public/vendor/magento/module-catalog/Helper/Image.php(470): Magento\Catalog\Helper\Image->initBaseFile()
      #1 /var/www/public/vendor/magento/module-catalog/Helper/Image.php(528): Magento\Catalog\Helper\Image->applyScheduledActions()
      #2 /var/www/public/app/design/frontend/Falak/englishfalak/Magento_Sales/templates/email/items/invoice/default.phtml(30): Magento\Catalog\Helper\Image->getUrl()
      #3 /var/www/public/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/www/public...')
      #4 /var/www/public/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Sales\Block\Order\Email\Items\DefaultItems\Interceptor), '/var/www/public...', Array)
      #5 /var/www/public/generated/code/Magento/Sales/Block/Order/Email/Items/DefaultItems/Interceptor.php(180): Magento\Framework\View\Element\Templa in /var/www/public/vendor/magento/module-catalog/Helper/Image.php on line 500, referer: http://lifestyley.localhost/admin/sales/invoice/view/order_id/123/invoice_id/4/key/ca0c7bf344bba27a0ed4dc1353f1f81c98c4c30764c9640ff79dd10108313c75/


      Why it's not working in the invoice template but working on the order template?



      The variable $_item is there in both of them and is retrieved in the same way in both cases. And in both files, I'm using several functions on this variable successfully. The only problem seems when I try to retrieve the products pictures.







      magento2 email email-templates invoice order-email






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 '18 at 11:06









      Hassan Al-JeshiHassan Al-Jeshi

      21228




      21228




















          3 Answers
          3






          active

          oldest

          votes


















          1














          My problem has been solved (thanks to xdebug :) by replacing $_item->getProduct() that I used in the order email template with $_item->getOrderItem()->getProduct()



          That's after noticing that the $_item in the invoice is different then $_item in the order and I need to use getOrderItem() function to retrieve the order item object.






          share|improve this answer






























            1














            You can use following code



            $product_id=1;

            $objectManager = MagentoFrameworkAppObjectManager::getInstance();

            $product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


            Then you can get image url like this:



            $this->helper('MagentoCatalogHelperImage')
            ->init($product, 'product_thumbnail_image')
            ->constrainOnly(TRUE)
            ->keepAspectRatio(TRUE)
            ->keepTransparency(TRUE)
            ->keepFrame(FALSE)
            ->resize(200, 260)->getUrl();





            share|improve this answer

























            • Thanks for the answer. But I don't want to use the ObjectManager directly.

              – Hassan Al-Jeshi
              Nov 25 '18 at 13:53











            • I have just added reference using that you can achieve your result. And also you can shift your code in block file or else you can create function for get product instance from helper class.

              – Pragnadeep Pitroda
              Nov 25 '18 at 13:56



















            0














            You need to load all items from invoice. Most likely you'll go with loading invoice by id -> load order -> load items -> get images for each item.



            Your problem can be linked to that one order can have multiple invoices.



            Here is example code, I didn't test it.



            <?php

            $orderIncrementId = '10101010'; // See how to get order Id from invoice
            $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
            $items = $order->getAllVisibleItems();
            foreach($items as $i):
            echo $i->getProductId(); // Will return product id
            echo $i->getImageUrl(); //Not sure but will return image url
            endforeach;





            share|improve this answer























            • Thanks for your answer. But I think it's for Magento 1, not 2.

              – Hassan Al-Jeshi
              Nov 25 '18 at 11:33











            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f251220%2fhow-to-get-the-product-image-in-invoice-email-template%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            My problem has been solved (thanks to xdebug :) by replacing $_item->getProduct() that I used in the order email template with $_item->getOrderItem()->getProduct()



            That's after noticing that the $_item in the invoice is different then $_item in the order and I need to use getOrderItem() function to retrieve the order item object.






            share|improve this answer



























              1














              My problem has been solved (thanks to xdebug :) by replacing $_item->getProduct() that I used in the order email template with $_item->getOrderItem()->getProduct()



              That's after noticing that the $_item in the invoice is different then $_item in the order and I need to use getOrderItem() function to retrieve the order item object.






              share|improve this answer

























                1












                1








                1







                My problem has been solved (thanks to xdebug :) by replacing $_item->getProduct() that I used in the order email template with $_item->getOrderItem()->getProduct()



                That's after noticing that the $_item in the invoice is different then $_item in the order and I need to use getOrderItem() function to retrieve the order item object.






                share|improve this answer













                My problem has been solved (thanks to xdebug :) by replacing $_item->getProduct() that I used in the order email template with $_item->getOrderItem()->getProduct()



                That's after noticing that the $_item in the invoice is different then $_item in the order and I need to use getOrderItem() function to retrieve the order item object.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 25 '18 at 13:56









                Hassan Al-JeshiHassan Al-Jeshi

                21228




                21228























                    1














                    You can use following code



                    $product_id=1;

                    $objectManager = MagentoFrameworkAppObjectManager::getInstance();

                    $product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


                    Then you can get image url like this:



                    $this->helper('MagentoCatalogHelperImage')
                    ->init($product, 'product_thumbnail_image')
                    ->constrainOnly(TRUE)
                    ->keepAspectRatio(TRUE)
                    ->keepTransparency(TRUE)
                    ->keepFrame(FALSE)
                    ->resize(200, 260)->getUrl();





                    share|improve this answer

























                    • Thanks for the answer. But I don't want to use the ObjectManager directly.

                      – Hassan Al-Jeshi
                      Nov 25 '18 at 13:53











                    • I have just added reference using that you can achieve your result. And also you can shift your code in block file or else you can create function for get product instance from helper class.

                      – Pragnadeep Pitroda
                      Nov 25 '18 at 13:56
















                    1














                    You can use following code



                    $product_id=1;

                    $objectManager = MagentoFrameworkAppObjectManager::getInstance();

                    $product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


                    Then you can get image url like this:



                    $this->helper('MagentoCatalogHelperImage')
                    ->init($product, 'product_thumbnail_image')
                    ->constrainOnly(TRUE)
                    ->keepAspectRatio(TRUE)
                    ->keepTransparency(TRUE)
                    ->keepFrame(FALSE)
                    ->resize(200, 260)->getUrl();





                    share|improve this answer

























                    • Thanks for the answer. But I don't want to use the ObjectManager directly.

                      – Hassan Al-Jeshi
                      Nov 25 '18 at 13:53











                    • I have just added reference using that you can achieve your result. And also you can shift your code in block file or else you can create function for get product instance from helper class.

                      – Pragnadeep Pitroda
                      Nov 25 '18 at 13:56














                    1












                    1








                    1







                    You can use following code



                    $product_id=1;

                    $objectManager = MagentoFrameworkAppObjectManager::getInstance();

                    $product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


                    Then you can get image url like this:



                    $this->helper('MagentoCatalogHelperImage')
                    ->init($product, 'product_thumbnail_image')
                    ->constrainOnly(TRUE)
                    ->keepAspectRatio(TRUE)
                    ->keepTransparency(TRUE)
                    ->keepFrame(FALSE)
                    ->resize(200, 260)->getUrl();





                    share|improve this answer















                    You can use following code



                    $product_id=1;

                    $objectManager = MagentoFrameworkAppObjectManager::getInstance();

                    $product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);


                    Then you can get image url like this:



                    $this->helper('MagentoCatalogHelperImage')
                    ->init($product, 'product_thumbnail_image')
                    ->constrainOnly(TRUE)
                    ->keepAspectRatio(TRUE)
                    ->keepTransparency(TRUE)
                    ->keepFrame(FALSE)
                    ->resize(200, 260)->getUrl();






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Apr 18 at 7:51









                    Hassan Al-Jeshi

                    21228




                    21228










                    answered Nov 25 '18 at 11:48









                    Pragnadeep PitrodaPragnadeep Pitroda

                    566




                    566












                    • Thanks for the answer. But I don't want to use the ObjectManager directly.

                      – Hassan Al-Jeshi
                      Nov 25 '18 at 13:53











                    • I have just added reference using that you can achieve your result. And also you can shift your code in block file or else you can create function for get product instance from helper class.

                      – Pragnadeep Pitroda
                      Nov 25 '18 at 13:56


















                    • Thanks for the answer. But I don't want to use the ObjectManager directly.

                      – Hassan Al-Jeshi
                      Nov 25 '18 at 13:53











                    • I have just added reference using that you can achieve your result. And also you can shift your code in block file or else you can create function for get product instance from helper class.

                      – Pragnadeep Pitroda
                      Nov 25 '18 at 13:56

















                    Thanks for the answer. But I don't want to use the ObjectManager directly.

                    – Hassan Al-Jeshi
                    Nov 25 '18 at 13:53





                    Thanks for the answer. But I don't want to use the ObjectManager directly.

                    – Hassan Al-Jeshi
                    Nov 25 '18 at 13:53













                    I have just added reference using that you can achieve your result. And also you can shift your code in block file or else you can create function for get product instance from helper class.

                    – Pragnadeep Pitroda
                    Nov 25 '18 at 13:56






                    I have just added reference using that you can achieve your result. And also you can shift your code in block file or else you can create function for get product instance from helper class.

                    – Pragnadeep Pitroda
                    Nov 25 '18 at 13:56












                    0














                    You need to load all items from invoice. Most likely you'll go with loading invoice by id -> load order -> load items -> get images for each item.



                    Your problem can be linked to that one order can have multiple invoices.



                    Here is example code, I didn't test it.



                    <?php

                    $orderIncrementId = '10101010'; // See how to get order Id from invoice
                    $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
                    $items = $order->getAllVisibleItems();
                    foreach($items as $i):
                    echo $i->getProductId(); // Will return product id
                    echo $i->getImageUrl(); //Not sure but will return image url
                    endforeach;





                    share|improve this answer























                    • Thanks for your answer. But I think it's for Magento 1, not 2.

                      – Hassan Al-Jeshi
                      Nov 25 '18 at 11:33















                    0














                    You need to load all items from invoice. Most likely you'll go with loading invoice by id -> load order -> load items -> get images for each item.



                    Your problem can be linked to that one order can have multiple invoices.



                    Here is example code, I didn't test it.



                    <?php

                    $orderIncrementId = '10101010'; // See how to get order Id from invoice
                    $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
                    $items = $order->getAllVisibleItems();
                    foreach($items as $i):
                    echo $i->getProductId(); // Will return product id
                    echo $i->getImageUrl(); //Not sure but will return image url
                    endforeach;





                    share|improve this answer























                    • Thanks for your answer. But I think it's for Magento 1, not 2.

                      – Hassan Al-Jeshi
                      Nov 25 '18 at 11:33













                    0












                    0








                    0







                    You need to load all items from invoice. Most likely you'll go with loading invoice by id -> load order -> load items -> get images for each item.



                    Your problem can be linked to that one order can have multiple invoices.



                    Here is example code, I didn't test it.



                    <?php

                    $orderIncrementId = '10101010'; // See how to get order Id from invoice
                    $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
                    $items = $order->getAllVisibleItems();
                    foreach($items as $i):
                    echo $i->getProductId(); // Will return product id
                    echo $i->getImageUrl(); //Not sure but will return image url
                    endforeach;





                    share|improve this answer













                    You need to load all items from invoice. Most likely you'll go with loading invoice by id -> load order -> load items -> get images for each item.



                    Your problem can be linked to that one order can have multiple invoices.



                    Here is example code, I didn't test it.



                    <?php

                    $orderIncrementId = '10101010'; // See how to get order Id from invoice
                    $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
                    $items = $order->getAllVisibleItems();
                    foreach($items as $i):
                    echo $i->getProductId(); // Will return product id
                    echo $i->getImageUrl(); //Not sure but will return image url
                    endforeach;






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 25 '18 at 11:25









                    Nikola PavlovićNikola Pavlović

                    11




                    11












                    • Thanks for your answer. But I think it's for Magento 1, not 2.

                      – Hassan Al-Jeshi
                      Nov 25 '18 at 11:33

















                    • Thanks for your answer. But I think it's for Magento 1, not 2.

                      – Hassan Al-Jeshi
                      Nov 25 '18 at 11:33
















                    Thanks for your answer. But I think it's for Magento 1, not 2.

                    – Hassan Al-Jeshi
                    Nov 25 '18 at 11:33





                    Thanks for your answer. But I think it's for Magento 1, not 2.

                    – Hassan Al-Jeshi
                    Nov 25 '18 at 11:33

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f251220%2fhow-to-get-the-product-image-in-invoice-email-template%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Sum ergo cogito? 1 nng

                    419 nièngy_Soadمي 19bal1.5o_g

                    Queiggey Chernihivv 9NnOo i Zw X QqKk LpB