Magento – Magento 2: How to get product url in order email

email-templatesmagento2sales

I am trying to get the product url along with product name in

app/design/frontend/yourPackage/yourtemplate/template/email/order/items/order/default.phtml

Here is the code that gets the product name and sku. Is there any function that can return the product url to be used in the email as a clickable link?

<p class="product-name"><?= $block->escapeHtml($_item->getName()) ?></p>
<p class="sku"><?= /* @escapeNotVerified */  __('SKU'); ?>: <?= $block->escapeHtml($block->getSku($_item)) ?></p>

Best Answer

You try with :

<?php /** @var $block \Magento\Bundle\Block\Sales\Order\Items\Renderer */ ?>
<?php $_item = $block->getItem() ?>
<?php $product_url= $_item->getProduct()->getProductUrl(); // Our code here?>
Related Topic