1

I am developing a solution with an external payment gateway. I create the order and then send the user to the gateway. When coming back from the gateway with a success i resend the order confirmation in my custom callback controller.

But the order confirmation email is sent once already when the order is first created. How do i intervene and stop this? I does not seem to find the correct event to do this in using an observer.

0

I think a better approach would be to add any additional functionality that your are trying to achieve to magento order email. By creating your own order email will limit functionality such as "resend order email".

But if you want continue take a look at send(Order $order, $forceSyncMode = false) in magento2/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php

In your custom module create etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="\Magento\Sales\Model\Order\Email\Sender\OrderSender" type="Company\ModuleName\Model\Order\Email\Sender\OrderSender"/>
</config>
  • Thanks! Should be able to solve it with this information. – nenne Feb 26 '16 at 8:32
  • I am new to magento2 and developing a custom module for CCavenue payment gateway.I am facing the same issue.Please explain how you solve this issue – Renjith R Jan 13 '17 at 7:25
  • @RenonStewart How to override the prepareTemplate function? i want to add a couple of additional data for email template – Idham Choudry Feb 10 '17 at 3:32
  • @IdhamChoudry Since it is a protected method you can NOT use plugin, so you would have to use a preference to rewrite the class as shown in the example above. Sometimes you may need to extend the original class when rewriting class – Renon Stewart Feb 10 '17 at 14:34
  • @RenonStewart : How to override the prepareTemplate() from vendor\magento\module-sales\Model\Order\Email\Sender.php function? i want to add a couple of additional data for email template. I have override using preference but its calling core prepareTemplate() method. Please help me. since, week I sucked here. – Pramod Kharade Jun 7 '17 at 12:04

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.