I want to implement an pdf attachment to my invoice mail to the customer. I have a pretty good guess on how to do that, however this time I would like to solve the task with an event observer.

Not having worked much with Magento Observers before, I have some troubles figuring out which event to hook into.

What I need is an event which happens when the standard email is composed, so that I can simply attach my pdf copy of the invoice. Funnily enough all the helpful sites I found on the internet omit exactly on explaining that step in order to keep the tutorial generic or something.

Any hint about the event, or even better on a generic way to figure out the right event to use in any task, would be greatly appreciated. Thank you.

  • You ,you check this link bluehorse.in/blog/… – Amit Bera Jul 1 '14 at 10:12
  • Thanks for the link. Looks like this one uses the rewrite approach, though. I might have to resort to that, so I appreciate the hint. – user3154108 Jul 1 '14 at 10:33

Afaik there is still no event in the while mailing system of magento. Neither in Mage_Core_Model_Email_Template nor in Mage_Core_Model_Email therefore you have to do what Samir is part 3 to rewrite the sending class add your own event and register an observer on it or just rewrite the class and add your attachement directly.

You should checkout Fooman_EmailAttachments: https://github.com/fooman/emailattachments

@fooman adds the events here app/code/community/Fooman/EmailAttachments/Model/Core/Email/Template/Mailer.php

  • That'll do. Thanks for pointing me the way. – user3154108 Jul 1 '14 at 12:10
  1. check the modules if you can find there something like 'dispatch' or observer
  2. to get an overview use the search from your ide with 'dispatch' or Observer
  3. If you cant find anything you can create your own observer, and add the dispatch where you need it by overriding the Model(s) in your custom module
  • Thanks, I guess I shouldn't have expected a less effortful way to figure the events out. It's Magento after all ;) – user3154108 Jul 1 '14 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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