Skip to content

Commit

Permalink
newsletter/template add before/after events
Browse files Browse the repository at this point in the history
  • Loading branch information
rjocoleman committed Jun 1, 2022
1 parent 75e8ba4 commit 3d5b821
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
| model_save_after | 1.9.4.5 |
| model_save_before | 1.9.4.5 |
| model_save_commit_after | 1.9.4.5 |
| newsletter_send_before | 1.9.4.6 |
| newsletter_send_after | 1.9.4.6 |
| on_view_report | 1.9.4.5 |
| order_cancel_after | 1.9.4.5 |
| page_block_html_topmenu_gethtml_after | 1.9.4.5 |
Expand Down
23 changes: 22 additions & 1 deletion app/code/core/Mage/Newsletter/Model/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,28 @@ public function send($subscriber, array $variables = array(), $name = null, Mage
$mail->setFrom($this->getTemplateSenderEmail(), $this->getTemplateSenderName());

try {
$mail->send();
$transport = new Varien_Object();

Mage::dispatchEvent('newsletter_send_before', [
'mail' => $mail,
'transport' => $transport,
'template' => $this,
'subscriber' => $subscriber
]);

if ($transport->getTransport()) {
$mail->send($transport->getTransport());
} else {
$mail->send();
}

Mage::dispatchEvent('newsletter_send_after', [
'to' => $email,
'html' => !$this->isPlain(),
'queue' => $queue,
'subject' => $mail->getSubject(),
'email_body' => $text
]);
$this->_mail = null;
if (!is_null($queue)) {
$subscriber->received($queue);
Expand Down

0 comments on commit 3d5b821

Please sign in to comment.