【问题标题】:Add custom product attribute to Magento transactional email将自定义产品属性添加到 Magento 交易电子邮件
【发布时间】:2014-10-23 09:19:45
【问题描述】:

我有一个自定义属性(我想这就是它的名字,我是 Magento 的新手。)

这需要通过 email/order/items/order/default.phtml

显示在一些交易电子邮件上

在产品页面视图中看起来像这样:

<?php echo $_product->getAttributeText('designer'); ?>

但是当它被复制到电子邮件模板中时,没有任何显示。尝试了几种不同的方法,但到目前为止都没有运气。

【问题讨论】:

    标签: php magento


    【解决方案1】:

    如果您想要该变量的值而不是将该值设置为电子邮件模板变量。 例如:

    $emailTemplate->setTemplateSubject('test subject');
                                    $emailTemplate->setSenderName('your Name');
                                    $emailTemplate->setSenderEmail('info@test.com');
                                    $emailTemplateVariables = array();
                                    $emailTemplateVariables['designer'] = $_product->getAttributeText('designer');
                                    $emailTemplate->getProcessedTemplate($emailTemplateVariables);     
                                    $emailTemplate->send($email, $emailTemplateVariables);
    

    以上注意这一点

    $emailTemplateVariables['designer'] = $_product->getAttributeText('designer');
    

    这将设置您可以在电子邮件模板中使用的模板变量“designer”。

    希望这会有所帮助。

    【讨论】:

    • 谢谢,但是这些行应该添加到哪里?
    • 你可以通过许多不同的方式来完成它。你可能已经在控制器文件中完成了它,或者可能有一个观察者已经定义了邮件发送功能。例如:如果你在之后发送电子邮件已下订单,而不是在 sales/controller/ 中或可能在 sales/model/observer 中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-31
    • 1970-01-01
    • 1970-01-01
    • 2016-06-09
    • 1970-01-01
    • 2019-11-15
    相关资源
    最近更新 更多