Override the MagentoCatalogModelLayerFilterList
in Magento 2.2.3 using plugin. This error came
PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed
to ####PluginModelLayerFilterList::aroundGetFilters() must
implement interface
MagentoCatalogModelLayerFilterableAttributeListInterface, instance
of Closure given, called in/magento/framework/Interception/Interceptor.php on line 135 and defined in ####/Plugin/Model/Layer/FilterList.php:70
preference is not working on this file.
3
Answers
Using virtual_type
Once Verify the core file of di.xml arguments passing
..../modulename/extensionmodule/etc/frontend/di.xml
..../modulename/extensionmodule/ModelLayer
You cannot override the class by plugin. If you want to override the class then just use the following code in your di.xml
If this not works then goto the parent class (MagentoCatalogModelLayerFilterList) and check the no of arugments you are sending from __contruct function of your module’s FilterList.php. Pass same number of arguments with same order to your parent class. It will work.
Here is full code to Override MagentoCatalogModelLayerFilterList this class
I can use virtualType method for override instead of preference
registration.php
etc/module.xml
etc/frontend/di.xml
Model/Layer/FilterList.php