1

I'm aware that it's possible to call the HTML value by: {{customVar code=custom_variable_code}}

Question is simple: Is it possible to receive plain value of custom variable in email template (Magento 1.9.2.0) with some statement like: {{customVar code=custom_variable_code|plain}}? If it's not, are there any tips to get something like that to work?

1 Answer 1

2

It is but it'll require some coding.

In a nutshell this is how an email is sent

$template  = Mage::getModel('core/email_template')->loadDefault('[email identifier]');                                  

$template->send('[email protected]','John Doe', array(
   'myvar' => 'foo',
   'myvar2' => 'bar',
));

now we can access the variables using {{var myvar}} and {{var myvar2}}

So to inject your values you'll need to make modifications to the array with variables injected into the send method.

It depends on what email you want to change

3
  • I was thinking about using it in almost all email templates - to be more specific in their subjects. But as I see the more quicker and cleaner approach is to just create dedicated for emails custom variable with text value entered in html – then it's accessible everywhere without any reinventing of the wheel. Only hiccup is that there will be two same custom variables but one with i.e. email prefix.
    – versedi
    Commented Sep 5, 2015 at 18:18
  • @versedi hold one sec, let me check if there is an event you can use to inject them into every email\ Commented Sep 5, 2015 at 18:28
  • ok say there isn't an event but you could rewrite Mage_Core_Model_Email_Template_Filter from a custom module setting your vars in the _construct method or rewrite Mage_Core_Model_Email_Template setting them in the send method. It ain't perfect but it'll get the job done Commented Sep 5, 2015 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.