1

I want to display all my store products on one page, with a side menu to 'filter' on the available categories. Basicly the same view as a single categorie product list, but then with all products (of Default Category) and all main categories on the side bar. I've been searching the internet for two days and haven't found any (working) solution.

I'm using Magento 2.1, with a premium paid theme (Porto).

I've tried creating a page with this code as content:

{{block type="catalog/product_list" name="all.products.list" alias="products_list" category_id="2" template="catalog/product/list.phtml"}}

and adding XML in the design field.

<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>3</category_id></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name>
</action>
</block>
</reference>

However, the XML gets rejected and the content code doesn't show any products.

Is this such a 'hard' thing to do? I would expect Magento just having an overview of all products somewhere, but I can't seem to find it.

1

First thing you are using the Magento 1 code that will not work on Magneto2.

Add these xml and try it.

<referenceContainer name="content">
<block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
                    <container name="category.product.list.additional" as="additional" />
                    <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
                        <block class="Magento\Framework\View\Element\Template" as="default"/>
                    </block>
                    <block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="category.product.addto" as="addto">
                        <block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"
                               name="category.product.addto.compare" as="compare"
                               template="Magento_Catalog::product/list/addto/compare.phtml"/>
                    </block>
                    <block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="Magento_Catalog::product/list/toolbar.phtml">
                        <block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/>


                    </block>
                    <action method="setToolbarBlockName">
                        <argument name="name" xsi:type="string">product_list_toolbar</argument>
                    </action>
                </block>
        </referenceContainer>


    <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>
  • Using this code, I first get an error on the <attribute... part. When I only insert the top referenceContainer, it gives me "Invalid block type: Magento\Catalog\Block\Product\ProductList\Item\Container" errors on the page. Any idea how to fix this? – roy.stultiens Jul 6 '17 at 11:21
  • remove <attribute name="class" value="page-with-filter"/> this line and check. – Qaisar Satti Jul 6 '17 at 11:21
  • Still getting these errors: Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid block type: Magento\Catalog\Block\Product\ProductList\Item\Container Exception #1 (ReflectionException): Class Magento\Catalog\Block\Product\ProductList\Item\Container does not exist – roy.stultiens Jul 6 '17 at 11:25
  • @roy.stultiens I tested this code it is working fine without any error – Qaisar Satti Jul 6 '17 at 11:43
  • 1
    Got it to work! Removed the entire block containing the Magento\Catalog\Block\Product\ProductList\Item\Container class. This does result in the output I require. Thank you very much! – roy.stultiens Jul 6 '17 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.