Skip to content

Dispatch events for e-mail template variables #396

@tzyganu

Description

@tzyganu

I think there is a need for an event to be dispatched before calling setTemplateParams when an e-mail is sent. I often needed this to add extra information in e-mail templates (at least for 1.x version) and the only way I could do it is to rewrite the method. (or am I doing it wrong?)
Here is an example.
in Magento\Sales\Model\Order::sendNewOrderEmail() this code


$mailer->setTemplateParams(array(
       'order'        => $this,
       'billing'      => $this->getBillingAddress(),
       'payment_html' => $paymentBlockHtml
      )
);

can be


$params = new \Magento\Object(array(
       'order'        => $this,
       'billing'      => $this->getBillingAddress(),
       'payment_html' => $paymentBlockHtml
      ));

$this->_eventManager->dispatch('sales_order_new_email', array('params'=>$params));
$mailer->setTemplateParams($params->getData());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions