4

I want to send copy of order confirmation mail to another customer so for that i am using btn_sales_order_save_after event

and in observer construct i am adding

\Magento\Sales\Model\Order\Email\Sender $sender,
....
$this->sender = $sender;
......

And call method like this

 $order->setCustomerName($customerName);
$order->setCustomerEmail($customerEmail);
$this->sender->checkAndSend($order); 

But it gives this error

"Fatal Error: 'Cannot instantiate interface Magento\Sales\Model\Order\Email\Container\IdentityInterface' in 'magento\lib\internal\Magento\Framework\ObjectManager\Factory\Dynamic\Developer.php' on line 73";

is this right way to send copy of order confirmation email?

1 Answer 1

4

Take a look to this https://github.com/magento/magento2/blob/135f967/app/code/Magento/Quote/Observer/Webapi/SubmitObserver.php#L40-L58

I think the right object is use Magento\Sales\Model\Order\Email\Sender\OrderSender;

and use the method "send"

In my case, checkAndSend was protected and I cannot use from external the class

0

Your Answer

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

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