简体   繁体   English

在新订单邮件中将产品链接添加到sku(或产品名称)

[英]add product link to sku (or product name) in new order mail

hy, i'm trying to add a link to the new order email that the customer is getting when he is placeing a new order in magento (my version 1.6.2.0 ) 嗨,我正在尝试向客户在magento(我的版本1.6.2.0)下达新订单时获得的新订单电子邮件添加链接。

i have edited /public_html/app/design/frontend/base/default/template/email/order/items/order/default.phtml with the following: 我用以下代码编辑了/public_html/app/design/frontend/base/default/template/email/order/items/order/default.phtml:

<?php $_item = $this->getItem() ?>
<?php $_order = $this->getItem()->getOrder() ?>
----
<!-- Start of edit file -->  
<a href="<?php echo $this->getProductUrl($_item) ?>">
<?php echo $this->htmlEscape($this->getSku($_item)) ?></a>

When i receive the confirmation email in the sku column the color changes form black ( default css ) to light blue link like, but it does not have any link property as shown below: email_photo I have also tried : 当我在sku列中收到确认电子邮件时,颜色会从黑色(默认为CSS)更改为浅蓝色链接,但它没有任何链接属性,如下所示: email_photo我也尝试过:

<a href="<?php echo $this->getUrlPath($_item) ?>">
<?php echo $this->htmlEscape($this->getSku($_item)) ?></a>

and i end up with the same thing. 我最终得到了同样的东西。

Can anyone tell me what i'm doing wrong ? 谁能告诉我我在做什么错? Thanks. 谢谢。

In line 排队

<a href="<?php echo $this->getUrlPath($_item) ?>">

$this is an instance of block *Mage_Sales_Block_Order_Email_Items_Order_Default*. $ this是块* Mage_Sales_Block_Order_Email_Items_Order_Default *的实例。 It does not have a function getUrlPath() or getProductUrl. 它没有函数getUrlPath()或getProductUrl。

You should use your $_item variable to get a product object and then it to get its URL 您应该使用$ _item变量获取产品对象,然后再获取其URL

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

我之前尝试过此代码:

<a href="<?php echo $_item->getProduct()->getUrlPath() ?>"><?php echo $this->htmlEscape($this->getSku($_item)) ?></a>

Magento 2 Magento 2

To link a product name with its product page in your order emails, edit following files: 要在您的订单电子邮件中将产品名称与其产品页面链接,请编辑以下文件:

Magento_Sales/templates/email/items/order/default.phtml
Magento_Sales/templates/email/items/invoice/default.phtml
Magento_Sales/templates/email/items/shipment/default.phtml

To get the product URL, use the following snippet of code and insert it into a href attribute of the link. 要获取产品URL,请使用以下代码段并将其插入链接的href属性中。

<?= $_item->getProduct()->getProductUrl(); ?>

For example, 例如,

<p class="product-name"> <a href="<?= $_item->getProduct()->getProductUrl(); ?>"> <?= $block->escapeHtml($_item->getName()); ?> </a> </p>

The result of the snippet of code will be a clickable product name in Magento Emails. 代码片段的结果将是Magento电子邮件中的可点击产品名称。

Tutorial from: https://themes.email/magento/product-links-in-magento-order-emails.html 教程来自: https : //themes.email/magento/product-links-in-magento-order-emails.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM