0

I am working on magento 2.1.8. In the my dashboard There are orders listing. But i want the product name of that order also.

right now product name could be shown by clicking on the view all list. This order is coming from recent.phtml. I also tried to get the product name from. order>items>renderer>default.html The code i copy was this.

<?php echo $block->escapeHtml($_item->getName()) ?>

how ever i am still not able to get this. Can any body help me in this regard.?

1 Answer 1

4

You need to fetch order Items using getAllVisibleItems() function of order object.

You can print the Ordered Items name in recent.phtml using the below code in $_orders foreach loop:

foreach ($_order->getAllVisibleItems() as $_item) {
     echo $block->escapeHtml($_item->getName());
} 

Hope this help !!

3
  • works like a charm. just a last question is it possible to add the wish list in this section ?
    – tech_geek
    Oct 10, 2017 at 9:48
  • 1
    Yes it is possible to add wishlist block here. for this you need to add new block in xml for wishlist on dashboard. You can ask separate question for this if face any issue. Oct 10, 2017 at 9:52
  • Its good thanks but have a question: when i have 3 items in one order id it shows like item1 item2 item3. i want to show item1</br> item2</br> item3... with image of product. any help?
    – MGPM
    May 14, 2019 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.