Question

I'm trying to overwrite only this file but I'm having no luck in it working, am I doing something wrong?

vendor/mageplaza/module-lazy-loading/Plugin/Model/Template/Filter.php

app/code/MySite/LazyLoading/etc/di.xml

<?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="Mageplaza\LazyLoading\Plugin\Model\Template" type="MySite\LazyLoading\Plugin\Model\Template"/>
</config>

app/code/MySite/LazyLoading/etc/module.xml

<?xml version="1.0"?>
  <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
  <module name="MySite_LazyLoading" setup_version="1.0.0">
  </module>
</config>

app/code/MySite/LazyLoading/registration.php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'MySite_LazyLoading',
    __DIR__
);

app/code/MySite/LazyLoading/Plugin/Model/Template/Filter.php

namespace MySite\LazyLoading\Plugin\Model\Template;

use Magento\Cms\Model\Template\Filter as CmsFilter;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem\Io\File;
use Mageplaza\LazyLoading\Helper\Data as HelperData;
use Mageplaza\LazyLoading\Helper\Image as HelperImage;
use Mageplaza\LazyLoading\Model\Config\Source\System\LoadingType;
use Mageplaza\LazyLoading\Model\Config\Source\System\PlaceholderType;

etc...

Afterward a setup:upgrade and cache:clean is done but no updated changes are showing

No correct solution

OTHER TIPS

You're overriding a Plugin so will need to disable or overwrite the Mageplaza one in the module di.xml

<type name="Mageplaza\LazyLoading\Plugin\Model\Template\Filter">
    <plugin name="filter" disabled="true" />
    <plugin name="mysite_filter" type="MySite\LazyLoading\Plugin\Model\Template\Filter" sortOrder="1" />
</type>

The answer here has more details: How to override or disable core Plugins in Magento2?

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top