Magento 2.1 – Get Product Name for Order in Dashboard

custom-optionsdashboardmagento-2.1ordersproduct

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.?

Best Answer

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 !!

Related Topic