I want to make the items clickable in the transactional mails. I modified the order mail (items/default.phtml) and added the following code:
<?php $_item = $block->getItem() ?>
<a href="<?= $_item->getProductUrl(); ?>"> <?= $block->escapeHtml($_item->getName()) ?></a>
However when I add the same code to the invoice mail (items/default.phtml) the value of getProductUrl() is empty.
How can I access the product URL in the invoice?
Thanks in advance.
Try this
$product_url= $_item->getOrderItem()->getProduct()->getProductUrl();
<p class="product-name"><a href="<?= /* @noEscape */ $product_url; ?>"><?= $block->escapeHtml($_item->getName()) ?></a></p>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.