I created a cms page with url key "allproducts", i add a layout.xml cms_page_view_id_allproducts.xml in my theme app\design\frontend\Vendor\Name\Magento_Cms\layout\
here is the content of the layout xml,
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="category.toolbar" template="Magento_Catalog::product/list/toolbar.phtml"/>
<block class="Magento\LayeredNavigation\Block\Navigation" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::layer/view.phtml"/>
<block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" template="Magento_Catalog::product/list.phtml">
<container name="category.product.list.additional" as="additional" />
</block>
</referenceContainer>
</body>
</page>
And Error is:
Error: Cannot instantiate interface Magento\Catalog\Model\Layer\FilterableAttributeListInterface in /var/www/example/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:50
but it is not work,do anyone how what is the simplest way to show all products with layered nav?
1 Answer 1
Yes, it is possible to add a CMS page in Magento 2 that displays all products with layered navigation. Here is a detailed process for accomplishing this task
Create a new CMS page: Content > Elements > Pages.
Add a block to the CMS page.
Configure the static block:
{{block class="Magento\Catalog\Block\Product\ListProduct" name="custom.products.list" template="Magento_Catalog::product/list.phtml"}}
{{block class="Magento\LayeredNavigation\Block\Navigation" name="catalog.leftnav" template="Magento_LayeredNavigation::layer/view.phtml"}}
Save the static block and CMS page.
Ensure that the necessary template files are present:
Make sure that the template files specified in the template attribute of the block directives are available in your theme or module. In this example, the list.phtml template file should exist in the Magento_Catalog module, and the view.phtml template file should exist in the Magento_LayeredNavigation module.
Clear the cache.