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 Answers 2

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

2
  • Hello @whiterabbit this answer helpful or not ??? Commented Apr 24, 2020 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. Commented Apr 28, 2020 at 11:57
0

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

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

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.