将自定义产品属性添加到Magento事务电子邮件中


Add custom product attribute to Magento transactional email

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

这需要通过email/order/items/order/default.phtml在一些交易性电子邮件上显示

在产品页面视图中是这样的:

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

但当它被复制到电子邮件模板中时,什么都不会显示。我尝试了一些不同的东西,但到目前为止没有运气。

如果您想要该变量的值,则已将该值设置为电子邮件模板变量。例如:

$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');

这将设置您可以在电子邮件模板中使用的模板变量"设计器"。

希望这会有所帮助。