Override Model from third party vendor in custom theme
Frage
I am trying to override a Model from a third Party vendor in a custom-theme. The original file was:
/vendor/3rdpartyompany/3rdpartymodule/Model/Formatter/BaseImage.php
I copied that file over to:
/vendor/customthemevendor/customtheme/Model/Formatter/BaseImage.php
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" />
</config>
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?
Lösung
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.
Thanks!
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange