I want to disable verification email sending from certain route. At first, I thought that I would create a plugin which would change the customer email to the dummy one before actually sending the email if the REQUEST_URI matches the condition, but adding some logic to the original method seems better option for me, however this method excepts different arguments.

The method name is "newAccount" of "Magento\Customer\Model\EmailVerification" class | Path: /vendor/magento/module-customer/Model/EmailNotification.php. My question is, is it possible to override this method using preference approach?

3 Answers 3


According to the standard practices of magento extension development, instead of "Preference" I advice to do the "Plugin" of that function.

The function is Public, so you can do the plugin it self according to your requirement.

  • Actually, there is a method call inside that method which I want to put inside if statement, however that method is private and I can't override that.
    – Hgresa
    Jul 29, 2021 at 13:28
  • In your question, you are asking the method name, that is public, so we provide you answer according to that one. Jul 29, 2021 at 13:31
  • But my question was if i could override that public method and you said use plugin so
    – Hgresa
    Jul 29, 2021 at 13:46
  • the best practices is plugin always instead of overiding for the public methods. Jul 29, 2021 at 13:48

I override this method normally adding all private methods in overriden class too


You can override any method using Magento overriding technique (Adding preference class and creating a similar method in it).

However if the method is public I suggest you to use plugin class instate overriding the class. Check if its possible to achieve using plugin otherwise override it.

Only if the method is private or protected then you have no choice except override it.

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.