0

I was trying to link the product name in the shipment mail to the product on our page, so the customer can click on the product name in the shipment mail.

I have tried with

$_item->getProduct()->getProductUrl()

but getProduct() returns null. The same code worked for the order confirmation mail.

Does anybody know how I can get the product URL?

Thanks

2 Answers2

0

Try this code :-

<?php 
    $_item = $block->getItem(); 
    $product_key = $_item->getProduct()->getUrlKey();    
    echo $product_key;
?>

More information :-

How to get "product url" for multi website in sales email template

Thanks...

Mohit Patel
  • 3,778
  • 4
  • 22
  • 52
  • Hello @whiterabbit this answer helpful or not ??? – Mohit Patel Apr 24 '20 at 12:10
  • Hi, so I already tried this one, but it doesn't work for shipping or creditmemo mails. It only works for confirmation mails, because $_item->getProduct() returns null for shipping and creditmemo mails. – whiterabbit Apr 28 '20 at 11:57
0

You need to use $_item->getOrderItem()->getProduct() in Shipment & Credit Memo email templates.

$_item->getOrderItem()->getProduct()->getProductUrl();
Chris Oliver
  • 178
  • 12