magento-lts icon indicating copy to clipboard operation
magento-lts copied to clipboard

Events around E-Mails

Open pquerner opened this issue 2 years ago • 2 comments

Description (*)

Because of PR #1438 I was thinking about having even more events around email, because as of know its difficult (to my knowledge) to disable certain emails from sending out. For instance I have a client which wants \Mage_Customer_Model_Customer::sendChangedPasswordOrEmail to never fire.

To do this, to my knowledge, you have to extend the full class. Which is ugly and not really that good in my opinion.

Adding more events around emails in the right places (which I currently do not know) would make it easy to disable certain emails from being sent out, right?

Expected behavior (*)

Having events in the right places added.

pquerner avatar Aug 18 '21 14:08 pquerner

As an alternative, for your consideration, the module aschroder/smtp_pro has many events related to e-mails - you can search for dispatchEvent in the module to see all of them. You also have some additional advantages such as more advanced SMTP/API integration and queueing.

rvelhote avatar Aug 24 '21 13:08 rvelhote

You could rewrite the Customer model overwriting just the one method to fire an event, before calling the parent method. Then you could use an observer to do what you're looking to do. It's not all that messy really.

That solves your problem short term. Why not then create a feature request for "customer_email_" prefixed email events... suggesting your then one of us can implement it one go.

Example:

Mage::dispatchEvent('customer_email_password_or_email', array(
   'model'    => $this
));

henryhayes avatar Nov 28 '21 20:11 henryhayes