I am trying to override a Model from a third Party vendor in a custom-theme. The original file was:


I copied that file over to:


and edited the namespace in that file:

namespace Customthemevendor\Customtheme\Model\Formatter;

Last I created a /etc/di.xml and set the preference:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="3rdPartyCompany\3rdPartyModule\Model\Formatter\BaseImage" type="Customthemevendor\Customtheme\Model\Formatter\BaseImage" />

Magento2 doesn't seem to recognize my customization at all. (Basically, there is a resize image function with hardcoded values in the function, that I need to change).

Is the Overriding-process the same for themes and modules or am I missing something?

  • You can override module in your custom module not in theme. Apr 14, 2021 at 7:33
  • So, there is no way to overriding it in the theme?
    – Mario
    Apr 14, 2021 at 7:36
  • No, you can only override layout, templates, css, js, web templates under theme. Apr 14, 2021 at 7:37
  • 1
    thank you. If you like, you can post that as an answer and I will mark it correct.
    – Mario
    Apr 14, 2021 at 7:40

1 Answer 1


You can only override layout, templates, css, js, web templates under theme.

So in order to override third party module model use plugin or preference in your custom module.


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.