magento2.3 – Block is rendered, but toHtml() function is not called

Using Magento Commerce 2.3.5-p2.

I’m changing the template of the layered navigation from a custom module like this:

<referenceBlock name="catalog.navigation.renderer"

This works correctly.

I am displaying images for some filters, and I want to have them lazy-loaded with Magefan_Lazyload.

The module has a plugin in frontend/di.xml:

<type name="MagentoFrameworkViewElementAbstractBlock">
        <plugin name="magefan_lazyload_lock"
                type="MagefanLazyLoadPluginBlockPlugin" sortOrder="1000"/>

In my opinion, this should work for all blocks that extend MagentoFrameworkViewElementAbstractBlock, so for example for all MagentoFrameworkViewElementTemplate blocks.

It works for some Template-blocks, but it doesn’t work for some other blocks, such as catalog.leftnav, or the one I am changing above.

I also added debug code to MagentoFrameworkViewElementAbstractBlock::toHtml(), and it seems that this method is never called for my block. Also, I don’t think the toHtml() method is overwritten somewhere.

Any tips?

I am running in developer mode. Strange enough, it works different in production mode – catalog.leftnav is recognized, but still not catalog.navigation.renderer.

I also tried changing the plugin’s sortOrder to 1, this didn’t work either.