I have to override InvoiceSender.php which path is Magento\Sales\Model\Order\Email\Sender\InvoiceSender

i am not able to overirde its function :

<preference type="module\name\Model\Order\Email\Sender\InvoiceSender" for="Magento\Sales\Model\Order\Email\Sender\InvoiceSender" /> 

1 Answer 1


You need to override by following xml code in di.xml

<preference type="Magento\Sales\Model\Order\Email\Sender\InvoiceSender" for="module\name\Model\Order\Email\Sender\InvoiceSender" /> 

You just interchanged the class name

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.