简体   繁体   中英

Add custom product attribute to Magento transactional email

I've got a custom attribute (I think that's what it's called, I'm new to Magento.)

This needs to be displayed on some transactional emails via email/order/items/order/default.phtml

It looks like this inside the product page view:

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

But nothing shows when this is copied into the email template. Have tried a few different things but no luck so far.

If you want the value of that variable than you have set that value to the email template variable. For example:

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

Above notice this

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

This will set the template variable "designer" which you can use in email template.

Hope this will help.

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.

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