2

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

1 Answer 1

3

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?>
3
  • In the template file at the top there is Jan 9, 2017 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> Jan 9, 2017 at 11:04
  • Don't need to add the top, you can use inside the template. Jan 9, 2017 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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