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


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>

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?>
  • In the template file at the top there is – John Elijah Jan 9 '17 at 10:49
  • In the template file at the top there is $_item = $block->getItem(); so should i try with <p class="product-name"><a href="<?= $_item->getProduct()->getProductUrl(); ?>"> <?= $block->escapeHtml($_item->getName()) ?></a></p> – John Elijah Jan 9 '17 at 11:04
  • Don't need to add the top, you can use inside the template. – Khoa TruongDinh Jan 9 '17 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.