{"id":154405,"date":"2018-12-22T13:35:19","date_gmt":"2018-12-22T13:35:19","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=154405"},"modified":"2024-02-29T13:45:18","modified_gmt":"2024-02-29T13:45:18","slug":"how-to-create-layered-navigation-on-custom-page-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/","title":{"rendered":"How to create layered navigation on custom page in Magento 2?"},"content":{"rendered":"\n<p>Today I&#8217;ll explain how you can add layered navigation to a custom page. In this example I&#8217;ll create a module named Webkul_LayeredNavigation and on&nbsp;layerednavigation\/index\/index page I&#8217;ll show the products with layered navigation.<\/p>\n\n\n\n<p>Here I&#8217;ll only explain those code which are necessary for implementation of the layered navigation.<\/p>\n\n\n\n<p><strong>P.S<\/strong> &#8211; You can check <a href=\"https:\/\/store.webkul.com\/magento2-ajax-layered-navigation.html\"><strong>Magento 2 Layered Navigation Extension<\/strong><\/a><\/p>\n\n\n\n<p>First create <strong>di.xml<\/strong>\u00a0with following code under <strong>Webkul\/LayeredNavigation\/etc\/<\/strong>\u00a0folder,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;..\/..\/..\/..\/..\/lib\/internal\/Magento\/Framework\/ObjectManager\/etc\/config.xsd&quot;&gt;\n    &lt;preference for=&quot;Magento\\Catalog\\Model\\Layer\\ContextInterface&quot; type=&quot;Magento\\Catalog\\Model\\Layer\\Context&quot; \/&gt;\n    &lt;preference for=&quot;Magento\\Catalog\\Model\\Layer\\ItemCollectionProviderInterface&quot; type=&quot;Magento\\Catalog\\Model\\Layer\\Category\\ItemCollectionProvider&quot; \/&gt;\n    &lt;preference for=&quot;Magento\\Catalog\\Model\\Layer\\StateKeyInterface&quot; type=&quot;Magento\\Catalog\\Model\\Layer\\Category\\StateKey&quot; \/&gt;\n    &lt;preference for=&quot;Magento\\Catalog\\Model\\Layer\\CollectionFilterInterface&quot; type=&quot;Magento\\Catalog\\Model\\Layer\\Category\\CollectionFilter&quot; \/&gt;\n    &lt;preference for=&quot;Magento\\Catalog\\Model\\Layer\\FilterableAttributeListInterface&quot; type=&quot;Magento\\Catalog\\Model\\Layer\\Category\\FilterableAttributeList&quot; \/&gt;\n    &lt;preference for=&quot;Magento\\Catalog\\Model\\Layer\\AvailabilityFlagInterface&quot; type=&quot;Magento\\Catalog\\Model\\Layer\\Category\\AvailabilityFlag&quot; \/&gt;\n    &lt;preference for=&quot;Magento\\Catalog\\Model\\ResourceModel\\Layer\\Filter\\Price&quot; type=&quot;Webkul\\LayeredNavigation\\Model\\ResourceModel\\Layer\\Filter\\Price&quot; \/&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p>Then add following in the layout file which in my case is\u00a0<strong>layerednavigation_index_index.xml\u00a0<\/strong>under\u00a0<strong>Webkul\/LayeredNavigation\/view\/frontend\/layout\/<\/strong> folder,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; layout=&quot;2columns-left&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n\t&lt;body&gt;\n        &lt;attribute name=&quot;class&quot; value=&quot;page-products&quot;\/&gt;\n        &lt;referenceContainer name=&quot;content&quot;&gt;\n            &lt;block class=&quot;Webkul\\LayeredNavigation\\Block\\Product\\ListProduct&quot; name=&quot;layerednavigation_index_index&quot; as=&quot;product_list&quot; template=&quot;Magento_Catalog::product\/list.phtml&quot;&gt;\n                &lt;container name=&quot;category.product.list.additional&quot; as=&quot;additional&quot; \/&gt;\n                &lt;block class=&quot;Magento\\Framework\\View\\Element\\RendererList&quot; name=&quot;category.product.type.details.renderers&quot; as=&quot;details.renderers&quot;&gt;\n                    &lt;block class=&quot;Magento\\Framework\\View\\Element\\Template&quot; name=&quot;category.product.type.details.renderers.default&quot; as=&quot;default&quot;\/&gt;\n                &lt;\/block&gt;\n                &lt;block class=&quot;Magento\\Catalog\\Block\\Product\\ProductList\\Item\\Container&quot; name=&quot;category.product.addto&quot; as=&quot;addto&quot;&gt;\n                    &lt;block class=&quot;Magento\\Catalog\\Block\\Product\\ProductList\\Item\\AddTo\\Compare&quot;\n                        name=&quot;category.product.addto.compare&quot; as=&quot;compare&quot;\n                        template=&quot;Magento_Catalog::product\/list\/addto\/compare.phtml&quot;\/&gt;\n                &lt;\/block&gt;\n                &lt;block class=&quot;Magento\\Catalog\\Block\\Product\\ProductList\\Toolbar&quot; name=&quot;product_list_toolbar&quot; template=&quot;Magento_Catalog::product\/list\/toolbar.phtml&quot;&gt;\n                    &lt;block class=&quot;Magento\\Theme\\Block\\Html\\Pager&quot; name=&quot;product_list_toolbar_pager&quot;\/&gt;\n                &lt;\/block&gt;\n                &lt;action method=&quot;setToolbarBlockName&quot;&gt;\n                    &lt;argument name=&quot;name&quot; xsi:type=&quot;string&quot;&gt;product_list_toolbar&lt;\/argument&gt;\n                &lt;\/action&gt;\n            &lt;\/block&gt;\n        &lt;\/referenceContainer&gt;\n        &lt;referenceContainer name=&quot;sidebar.main&quot;&gt;\n            &lt;block class=&quot;Webkul\\LayeredNavigation\\Block\\Navigation&quot; name=&quot;catalog.leftnav&quot; as=&quot;navigation&quot; before=&quot;-&quot; template=&quot;Magento_LayeredNavigation::layer\/view.phtml&quot;&gt;\n                &lt;block class=&quot;Webkul\\LayeredNavigation\\Block\\Navigation\\State&quot; name=&quot;catalog.navigation.state&quot; as=&quot;state&quot; template=&quot;Magento_LayeredNavigation::layer\/state.phtml&quot; \/&gt;\n                &lt;block class=&quot;Magento\\LayeredNavigation\\Block\\Navigation\\FilterRenderer&quot; name=&quot;catalog.navigation.renderer&quot; as=&quot;renderer&quot; template=&quot;Magento_LayeredNavigation::layer\/filter.phtml&quot;&gt;\n                  &lt;arguments&gt;\n                      &lt;argument name=&quot;product_layer_view_model&quot; xsi:type=&quot;object&quot;&gt;Magento\\LayeredNavigation\\ViewModel\\Layer\\Filter&lt;\/argument&gt;\n                  &lt;\/arguments&gt;\n                &lt;\/block&gt;\n            &lt;\/block&gt;\n        &lt;\/referenceContainer&gt;\n        &lt;referenceBlock name=&quot;layerednavigation_index_index&quot;&gt;\n             &lt;arguments&gt;\n                  &lt;argument name=&quot;viewModel&quot; xsi:type=&quot;object&quot;&gt;Magento\\Catalog\\ViewModel\\Product\\OptionsData&lt;\/argument&gt;\n             &lt;\/arguments&gt;\n        &lt;\/referenceBlock&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p>In the above code I have added <a href=\"https:\/\/webkul.com\/blog\/how-to-add-attribute-to-the-body-tag-in-magento-2\/\">class&nbsp;<strong>page-products&nbsp;<\/strong>to the body tag<\/a> to inherit the default styling.<\/p>\n\n\n\n<p>Now we will override the model files to get required data.<\/p>\n\n\n\n<p>Now create <strong>Layer.php<\/strong>\u00a0under\u00a0<strong>Webkul\/LayeredNavigation\/Model\/<\/strong> folder with following code,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\LayeredNavigation\\Model;\n\nuse Magento\\Catalog\\Api\\CategoryRepositoryInterface;\nuse Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\CollectionFactory as AttributeCollectionFactory;\nuse Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory;\n\nclass Layer extends \\Magento\\Catalog\\Model\\Layer\n{\n    public function __construct(\n        \\Magento\\Catalog\\Model\\Layer\\ContextInterface $context,\n        \\Magento\\Catalog\\Model\\Layer\\StateFactory $layerStateFactory,\n        AttributeCollectionFactory $attributeCollectionFactory,\n        \\Magento\\Catalog\\Model\\ResourceModel\\Product $catalogProduct,\n        \\Magento\\Store\\Model\\StoreManagerInterface $storeManager,\n        \\Magento\\Framework\\Registry $registry,\n        CategoryRepositoryInterface $categoryRepository,\n        CollectionFactory $productCollectionFactory,\n        array $data = &#091;]\n    ) {\n        $this-&gt;productCollectionFactory = $productCollectionFactory;\n        parent::__construct(\n            $context,\n            $layerStateFactory,\n            $attributeCollectionFactory,\n            $catalogProduct,\n            $storeManager,\n            $registry,\n            $categoryRepository,\n            $data\n        );\n    }\n\n\tpublic function getProductCollection()\n\t{\n        if (isset($this-&gt;_productCollections&#091;&#039;webkul_custom&#039;])) {\n            $collection = $this-&gt;_productCollections&#091;&#039;webkul_custom&#039;];\n        } else {\n            \/\/here you assign your own custom collection of products\n            $collection = $this-&gt;productCollectionFactory-&gt;create();\n            $this-&gt;prepareProductCollection($collection);\n            $this-&gt;_productCollections&#091;&#039;webkul_custom&#039;] = $collection;\n        }\n\t\treturn $collection;\n\t}\n\n}<\/pre>\n\n\n\n<p>After that create\u00a0<strong>Resolver.php\u00a0<\/strong>under\u00a0<strong>Webkul\/LayeredNavigation\/Model\/Layer\/<\/strong> folder with following code,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\LayeredNavigation\\Model\\Layer;\n\nclass Resolver extends \\Magento\\Catalog\\Model\\Layer\\Resolver\n{\n\tpublic function __construct(\n\t\t\\Magento\\Framework\\ObjectManagerInterface $objectManager,\n\t\t\\Webkul\\LayeredNavigation\\Model\\Layer $layer,\n\t\tarray $layersPool\n\t) {\n\t\t$this-&gt;layer = $layer;\n\t\tparent::__construct($objectManager, $layersPool);\n\t}\n\n\tpublic function create($layerType)\n\t{\n\t\t\n\t}\n}<\/pre>\n\n\n\n<p>Then under <strong>Webkul\/LayeredNavigation\/Model\/ResourceModel\/Layer\/Filter\/<\/strong> folder create\u00a0<strong>Price.php<\/strong> file,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\LayeredNavigation\\Model\\ResourceModel\\Layer\\Filter;\n\nuse Magento\\Framework\\App\\Http\\Context;\nuse Magento\\Framework\\Indexer\\DimensionFactory;\nuse Magento\\Framework\\Search\\Request\\IndexScopeResolverInterface;\n\nclass Price extends \\Magento\\Catalog\\Model\\ResourceModel\\Layer\\Filter\\Price \n{\n    public function __construct(\n        \\Magento\\Framework\\Model\\ResourceModel\\Db\\Context $context,\n        \\Magento\\Framework\\Event\\ManagerInterface $eventManager,\n        \\Webkul\\LayeredNavigation\\Model\\Layer\\Resolver $layerResolver,\n        \\Magento\\Customer\\Model\\Session $session,\n        \\Magento\\Store\\Model\\StoreManagerInterface $storeManager,\n        $connectionName = null,\n        IndexScopeResolverInterface $priceTableResolver = null,\n        Context $httpContext = null,\n        DimensionFactory $dimensionFactory = null\n    ) {\n        parent::__construct($context, $eventManager, $layerResolver, $session, $storeManager, $connectionName, $priceTableResolver, $httpContext, $dimensionFactory);\n    }\n}<\/pre>\n\n\n\n<p>Now we are done with the model and we will override the block to show proper data.<\/p>\n\n\n\n<p>Now create\u00a0<strong>Navigation.php\u00a0<\/strong>file under\u00a0<strong>Webkul\/LayeredNavigation\/Block\/<\/strong>\u00a0folder with following content,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\LayeredNavigation\\Block;\n\nclass Navigation extends \\Magento\\LayeredNavigation\\Block\\Navigation\n{\n\tpublic function __construct(\n\t\t\\Magento\\Framework\\View\\Element\\Template\\Context $context,\n\t\t\\Webkul\\LayeredNavigation\\Model\\Layer\\Resolver $layerResolver,\n\t\t\\Magento\\Catalog\\Model\\Layer\\FilterList $filterList,\n\t\t\\Magento\\Catalog\\Model\\Layer\\AvailabilityFlagInterface $visibilityFlag,\n\t\tarray $data = &#091;]\n\t) {\n\t\tparent::__construct($context, $layerResolver, $filterList,\n\t\t\t$visibilityFlag);\n\t}\n}<\/pre>\n\n\n\n<p>Then create\u00a0<strong>State.php<\/strong>\u00a0file under\u00a0<strong>Webkul\/LayeredNavigation\/Block\/Navigation\/<\/strong> folder with following code,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\LayeredNavigation\\Block\\Navigation;\n\nclass State extends \\Magento\\LayeredNavigation\\Block\\Navigation\\State\n{\n\u00a0\u00a0\u00a0\u00a0public function __construct(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\\Magento\\Framework\\View\\Element\\Template\\Context $context,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\\Webkul\\LayeredNavigation\\Model\\Layer\\Resolver $layerResolver,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0array $data = &#091;]\n\u00a0\u00a0\u00a0\u00a0) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0parent::__construct($context, $layerResolver, $data);\n}\n}<\/pre>\n\n\n\n<p>Then under\u00a0<strong>Webkul\/LayeredNavigation\/Block\/Product\/\u00a0<\/strong>folder create\u00a0<strong>ListProduct.php<\/strong>\u00a0and add following code,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\LayeredNavigation\\Block\\Product;\n\nclass ListProduct extends \\Magento\\Catalog\\Block\\Product\\ListProduct\n{\n\tpublic function __construct(\n\t\t\\Magento\\Catalog\\Block\\Product\\Context $context,\n\t\t\\Magento\\Framework\\Data\\Helper\\PostHelper $postDataHelper,\n\t\t\\Webkul\\LayeredNavigation\\Model\\Layer\\Resolver $layerResolver,\n\t\t\\Magento\\Catalog\\Api\\CategoryRepositoryInterface $categoryRepository,\n\t\t\\Magento\\Framework\\Url\\Helper\\Data $urlHelper,\n\t\tarray $data = &#091;]\n\t) {\n\t\tparent::__construct($context, $postDataHelper, $layerResolver,\n\t\t\t$categoryRepository, $urlHelper, $data);\n\t}\n}<\/pre>\n\n\n\n<p>That&#8217;s it, we have overridden all the required files.<\/p>\n\n\n\n<p>Now you can check the front-end and it should display the layered navigation on left side,<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1299\" height=\"655\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png\" alt=\"Custom page showing layered navigation\" class=\"wp-image-155385\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png 1299w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505-250x126.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505-300x151.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505-768x387.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505-1200x605.png 1200w\" sizes=\"(max-width: 1299px) 100vw, 1299px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Happy coding \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I&#8217;ll explain how you can add layered navigation to a custom page. In this example I&#8217;ll create a module named Webkul_LayeredNavigation and on&nbsp;layerednavigation\/index\/index page I&#8217;ll show the products with layered navigation. Here I&#8217;ll only explain those code which are necessary for implementation of the layered navigation. P.S &#8211; You can check Magento 2 Layered <a href=\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":201,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302,1],"tags":[7942,7943,7941],"class_list":["post-154405","post","type-post","status-publish","format-standard","hentry","category-magento2","category-uncategorized","tag-custom-product-collection","tag-layered-navigation-for-custom-page","tag-magento-2-layered-navigation"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create layered navigation on custom page in Magento 2? - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create layered navigation on custom page in Magento 2? - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Today I&#8217;ll explain how you can add layered navigation to a custom page. In this example I&#8217;ll create a module named Webkul_LayeredNavigation and on&nbsp;layerednavigation\/index\/index page I&#8217;ll show the products with layered navigation. Here I&#8217;ll only explain those code which are necessary for implementation of the layered navigation. P.S &#8211; You can check Magento 2 Layered [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-12-22T13:35:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-29T13:45:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png\" \/>\n<meta name=\"author\" content=\"Sanjay Chouhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sanjay Chouhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/\"},\"author\":{\"name\":\"Sanjay Chouhan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\"},\"headline\":\"How to create layered navigation on custom page in Magento 2?\",\"datePublished\":\"2018-12-22T13:35:19+00:00\",\"dateModified\":\"2024-02-29T13:45:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/\"},\"wordCount\":262,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png\",\"keywords\":[\"custom product collection\",\"layered navigation for custom page\",\"Magento 2 layered navigation\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/\",\"name\":\"How to create layered navigation on custom page in Magento 2? - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png\",\"datePublished\":\"2018-12-22T13:35:19+00:00\",\"dateModified\":\"2024-02-29T13:45:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png\",\"width\":1299,\"height\":655},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create layered navigation on custom page in Magento 2?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\",\"name\":\"Sanjay Chouhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sanjay Chouhan\"},\"sameAs\":[\"https:\/\/www.instagram.com\/sanjaychouhansc\/\",\"https:\/\/in.linkedin.com\/in\/scchouhansanjay\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create layered navigation on custom page in Magento 2? - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"How to create layered navigation on custom page in Magento 2? - Webkul Blog","og_description":"Today I&#8217;ll explain how you can add layered navigation to a custom page. In this example I&#8217;ll create a module named Webkul_LayeredNavigation and on&nbsp;layerednavigation\/index\/index page I&#8217;ll show the products with layered navigation. Here I&#8217;ll only explain those code which are necessary for implementation of the layered navigation. P.S &#8211; You can check Magento 2 Layered [...]","og_url":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-12-22T13:35:19+00:00","article_modified_time":"2024-02-29T13:45:18+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png","type":"","width":"","height":""}],"author":"Sanjay Chouhan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sanjay Chouhan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/"},"author":{"name":"Sanjay Chouhan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462"},"headline":"How to create layered navigation on custom page in Magento 2?","datePublished":"2018-12-22T13:35:19+00:00","dateModified":"2024-02-29T13:45:18+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/"},"wordCount":262,"commentCount":8,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png","keywords":["custom product collection","layered navigation for custom page","Magento 2 layered navigation"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/","name":"How to create layered navigation on custom page in Magento 2? - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png","datePublished":"2018-12-22T13:35:19+00:00","dateModified":"2024-02-29T13:45:18+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot_505.png","width":1299,"height":655},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-create-layered-navigation-on-custom-page-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create layered navigation on custom page in Magento 2?"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462","name":"Sanjay Chouhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sanjay Chouhan"},"sameAs":["https:\/\/www.instagram.com\/sanjaychouhansc\/","https:\/\/in.linkedin.com\/in\/scchouhansanjay"],"url":"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/154405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/201"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=154405"}],"version-history":[{"count":8,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/154405\/revisions"}],"predecessor-version":[{"id":425405,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/154405\/revisions\/425405"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=154405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=154405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=154405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}