$_item->getProduct() is used on Order Confirmation emails to get the product instance. This does not work on Shipment & Credit Memo emails. How can the Product instance (Not the item) be retrieved here?
-
In which file you are trying to get product ?– PawanCommented Dec 17, 2023 at 7:05
-
It was in Magento_Sales/templates/email/items/shipmet/default.phtml The solution is to use $_item->getOrderItem(). I belive this is the same for Shimpemt and Credit Memo email templates.– Chris OliverCommented Dec 18, 2023 at 12:38
Add a comment
|
2 Answers
The correct solution for me was to use.
$_item->getOrderItem();
to get the item instance. I then got the child items for configurables as such:
// Configurable Child Items
foreach($_orderItem->getChildrenItems() as $orderItem){
$productId = $orderItem->getId();
$productName = $orderItem->getName();
$productUrl = $orderItem->getProductUrl();
$productSku = $orderItem->getSku();
}
I didn't use nned to use getProduct(), that still returned null for some values.