0

$_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?

2
  • In which file you are trying to get product ?
    – Pawan
    Commented 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. Commented Dec 18, 2023 at 12:38

2 Answers 2

2

You can use $_item->getOrderItem()->getProduct()

Tom

1

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.

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.