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?

asked Apr 26, 2016 at 10:32

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

answered May 24, 2016 at 6:37
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.