elasticsuite
elasticsuite copied to clipboard
Filters in custom page with custom layer doens't respect product collection
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?
+1
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.
Too specific issue and too old, I close.
Regards