Reputation: 2790
Goal: Each time a transactional email is sent, pass the template text string through a helper class before sending.
I've basically got things working how I want. Except one thing that is a little annoying. I have copied /app/code/core/Mage/Model/Email/Template.php into it's local variant and added a single line in the getProcessedTemplate() method (~line 319)
Right before the result is returned, I pass it through the helper and my email is now awesome; however, I'd rather get this to work without having to hack up the core. Will I need to create a new event and observer to do this? Is there a friendlier method?
Upvotes: 0
Views: 1075
Reputation: 23205
Unfortunately there are no practical / useful event hooks in the case of core/email_template
class. Moreover, there are two classes which extend this class, meaning that using the include path priority is the only way to ensure that your definition is used in all cases.
You'll notice that the getProcessedTemplate()
method calls the _templateFilter
object's filter()
method. You could implement a class rewrite of core/email_template
via configuration and set the _templateFilter
in the overridden _construct
to use your own template filter class, adding whatever you need in your definition of filter()
. However, there's nothing to stop other code from calling setTemplateFilter()
, so you would need to accommodate that condition. Note that Mage_Newsletter_Model_Queue does this.
Not the answer you were hoping for, but HTH.
Upvotes: 2