0

Event is : checkout_onepage_controller_success_action

How can I send email to Same Customer again who placed order from observer?

Observer:

public function execute(Observer $observer)
{
    $orderIds = $observer->getEvent()->getOrderIds(); 
    if (count($orderIds)) {
        $orderId = $orderIds[0];            
        $order = $this->_orderFactory->create()->load($orderId); 
    }
}
3
  • found my answer Commented Feb 15, 2017 at 15:15
  • 1
    You should answer your question if you found answer yourself that will help other people. So please answer. Commented Feb 16, 2017 at 5:58
  • Yes, definitely buddy. Commented Feb 16, 2017 at 6:31

1 Answer 1

1

Added following code in my observer:

Use: use Magento\Sales\Model\Order\Email\Sender\OrderSender;

Declare variable in class:

protected $orderSender;

In constructor:

$this->orderSender = $orderSender;

In execute:

try {
         $this->orderSender->send($order);
    } catch (\Exception $e) {
         $this->logger->critical($e);
    }

It sends mail 2nd time to customer because customer already receives mail after order place.

In my module their is perticular need for that, So I'm using that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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