6

I saw this, but it don't work for me.

How to override Virtual Type class in Magento 2

<virtualType name="categoryFilterList" type="Magento\Catalog\Model\Layer\FilterList">
    <arguments>
        <argument name="filterableAttributes" xsi:type="object">Magento\Catalog\Model\Layer\Category\FilterableAttributeList</argument>
    </arguments>
</virtualType>
<virtualType name="searchFilterList" type="Magento\Catalog\Model\Layer\FilterList">
    <arguments>
        <argument name="filterableAttributes" xsi:type="object">Magento\Catalog\Model\Layer\Search\FilterableAttributeList</argument>
    </arguments>
</virtualType>

How to override Magento\Catalog\Model\Layer\FilterList ?

Plugin is creating successfully, but I'm unable to extend from parent class, as I need it's protected methods.

When I use preference - I'm facing with another issue. Magento is trying to create object from interface, which is impossible. As I understand it happen because it doesn't see

<arguments>
    <argument name="filterableAttributes" xsi:type="object">Magento\Catalog\Model\Layer\Search\FilterableAttributeList</argument>
</arguments>

The only way which is working for me - is overlapping config and setting sequence:

Copy config from above to my module and replace type to my own.

  • Did you use the name in the for section of the preference in your xml? – David Manners Jun 2 '17 at 13:49
  • categoryFilterList? Yep, I tried this too. I didnt dive deep inside the code, but I think that name should be similar as class plus namespace – zhartaunik Jun 3 '17 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.