PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

[FIXED] How to override Magento\Catalog\Model\Layer\FilterList in magento 2.2.3

 August 23, 2022     fatal-error, filter, magento, magento2, php     No comments   

Issue

Override the Magento\Catalog\Model\Layer\FilterList in Magento 2.2.3 using plugin. This error came

PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to ####\Plugin\Model\Layer\FilterList::aroundGetFilters() must implement interface Magento\Catalog\Model\Layer\FilterableAttributeListInterface, 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.


Solution

Using virtual_type

Once Verify the core file of di.xml arguments passing

..../modulename/extensionmodule/etc/frontend/di.xml

 <virtualType name="categoryFilterList" type="ModuleName\ExtensionModule\Model\Layer\FilterList">
    <arguments>
    Your Passing Arguments(same as existing core file - di.xml(core module) passing arguments ).

    </arguments>
</virtualType>

..../modulename/extensionmodule/Model\Layer

<?php

    namespace ModuleName\ExtensionModule\Model\Layer;
    
    /**
     * Override FilterList Class
     */
    class FilterList extends \Magento\Catalog\Model\Layer\FilterList
    {
        ......Your Code Here......
    }
    ?>


Answered By - Nandhini Nagaraj
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,214,376

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing