Skip to content

Magento 2.4 create custom filter for products in listpage

I’m migrating Magento 2.3 to 2.4.5. Already I have a working feature of a custom attribute filter in the Product list page also having a plugin but the class MagentoCatalogSearchModelSearchIndexBuilder doesn’t exist in Magento 2.4 for elastic search 7.

<type name="MagentoCatalogSearchModelSearchIndexBuilder">
        <plugin name="search_index_builder_restrict_product_after_get" type="VendorRestrictProductPluginCatalogSearchSearchIndexBuilder" />
</type>

Also applied the same logic here for

<type name="MagentoElasticsearch7ModelClientElasticsearch">
        <plugin name="search_es_restrict_product_after_get" type="VendorRestrictProductPluginElasticLayerPlugin" />
</type>

But the custom filter is not working. I’m using