I have a question about m2 preferences (overwriting core modules). Whenever I overwrite a core module, do I have to inject all the classes the same way original class does? Also what should I extend? The class that I'm trying to overwrite or the class that the overwritten class is extending?

1 Answer 1


Your class should extend the one that you're overwriting. It should contain the same parameters at a minimum because your constructor needs to call the parent constructor with the original parameters in order, i.e. parent::__construct($context, $data);. You can of course inject additional classes to use in your child class.

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.