I am trying to set a layered navigation filter on the custom cms page. for that, I have created a 1 cms page name test with two-column with left bar. and inside it, I have called one template file
{{block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/test.phtml"}}
in the CMS layout update, I have placed this code
<referenceContainer name="sidebar.main">
<block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.leftnav" before="-" template="layer/view.phtml">
<block class="Magento\LayeredNavigation\Block\Navigation\State" name="catalog.navigation.state" as="state" />
<block class="Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name="catalog.navigation.renderer" as="renderer" template="layer/filter.phtml"/>
</block>
</referenceContainer>
for calling product filter
inside the test.phtml file I have searched the products from the collection.
if(isset($_REQUEST["test"])) {
$productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$imageHelper = $objectManager->get('\Magento\Catalog\Helper\Image');
$collection = $productCollection->create()
->addAttributeToSelect('*')
->addAttributeToFilter('status',\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
->addAttributeToFilter('visibility', \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
->addAttributeToFilter('test', $_REQUEST["test"])
->load();
}
when I click on any of the filter options then my URL becomes
so can I get the filter request but it is a very tedious task to set a filter in collection manually.
And on the home page, I have set one search box for search products.
<form id="testsearch" action="http://127.0.0.1/magento/test" >
<div>Find Matching Part</div>
<div>
<input type="text" name="test">
<button type="submit">SEARCH</button>
</div>
</form>
I know that this is not a standard way to do that but anyone can help me to set this filter in custom cms page.
Any help would be appreciated.
Thanks in advance..!