elasticsuite icon indicating copy to clipboard operation
elasticsuite copied to clipboard

Filters in custom page with custom layer doens't respect product collection

Open sedax90 opened this issue 5 years ago • 2 comments

I've created a custom controller with a custom layer following this guide: https://webkul.com/blog/how-to-create-layered-navigation-on-custom-page-in-magento-2/

I've added to my frontend/di.xml some modifications following elasticsuite-catalog module:

<type name="Dexanet\Dealer\Block\Navigation">
        <arguments>
            <argument name="filterList" xsi:type="object">categoryFilterList</argument>
        </arguments>
    </type>

   <type name="Dexanet\Dealer\Model\Layer">
        <arguments>
            <argument name="context" xsi:type="object">Magento\CatalogSearch\Model\Layer\Category\Context</argument>
            <argument name="productCollectionFactory" xsi:type="object">Magento\CatalogSearch\Model\ResourceModel\Fulltext\CollectionFactory</argument>
        </arguments>
    </type>

    <type name="Dexanet\Dealer\Model\Layer">
        <plugin name="createSortOrdersOnPrepareFrontCollection" type="Smile\ElasticsuiteCatalog\Plugin\LayerPlugin"/>
    </type>

The page now show correct products besed on the filtered collection defined in layer but products count and filters are wrong. Do I still have to include something?

sedax90 avatar Oct 01 '19 15:10 sedax90

+1

ionpan avatar Dec 20 '19 14:12 ionpan

I don't think there's anything wrong with your code.

This module, changes the Layer Collection provider with a virtual type in thier di to: "Magento\Catalog\Model\Layer\Search\ItemCollectionProvider"

This won't act normally,

It should be loading: "\Magento\Catalog\Model\Layer\Category\ItemCollectionProvider" when no search options are enabled for that category. I'm having the same problem, but I haven't solved this yet, it'll need a pull request and a module update. When I find a solve I'll update this issue.

tschirmer avatar Jan 15 '20 23:01 tschirmer

Too specific issue and too old, I close.

Regards

romainruaud avatar Oct 18 '23 13:10 romainruaud