Magento2 - Custom Product Collection with Layered Navigation









up vote
9
down vote

favorite












I am trying to display Layered Navigation Block on custom page with custom product list.



For now i have custom controller, xml layout and template for product list.



  1. What do i need to insert into xml layout to display layered navigation block ?

<referenceContainer name="sidebar.main">
<!-- ??? -->
</referenceContainer>



  1. How can i set custom product collection (filtered by attribute e.g. 'book' == 1) and use it (with layered navigation) on custom page (e.g. book list with author filter) ?









share|improve this question

























    up vote
    9
    down vote

    favorite












    I am trying to display Layered Navigation Block on custom page with custom product list.



    For now i have custom controller, xml layout and template for product list.



    1. What do i need to insert into xml layout to display layered navigation block ?

    <referenceContainer name="sidebar.main">
    <!-- ??? -->
    </referenceContainer>



    1. How can i set custom product collection (filtered by attribute e.g. 'book' == 1) and use it (with layered navigation) on custom page (e.g. book list with author filter) ?









    share|improve this question























      up vote
      9
      down vote

      favorite









      up vote
      9
      down vote

      favorite











      I am trying to display Layered Navigation Block on custom page with custom product list.



      For now i have custom controller, xml layout and template for product list.



      1. What do i need to insert into xml layout to display layered navigation block ?

      <referenceContainer name="sidebar.main">
      <!-- ??? -->
      </referenceContainer>



      1. How can i set custom product collection (filtered by attribute e.g. 'book' == 1) and use it (with layered navigation) on custom page (e.g. book list with author filter) ?









      share|improve this question













      I am trying to display Layered Navigation Block on custom page with custom product list.



      For now i have custom controller, xml layout and template for product list.



      1. What do i need to insert into xml layout to display layered navigation block ?

      <referenceContainer name="sidebar.main">
      <!-- ??? -->
      </referenceContainer>



      1. How can i set custom product collection (filtered by attribute e.g. 'book' == 1) and use it (with layered navigation) on custom page (e.g. book list with author filter) ?






      magento2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 11 '16 at 8:12









      kaspi

      464




      464






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          The XML you need can be found in Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml



          The snippet you'll need to add to your referenceContainer is:



          <block class="MagentoLayeredNavigationBlockNavigationCategory" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::layer/view.phtml">
          <block class="MagentoLayeredNavigationBlockNavigationState" name="catalog.navigation.state" as="state" />
          <block class="MagentoLayeredNavigationBlockNavigationFilterRenderer" name="catalog.navigation.renderer" as="renderer" template="Magento_LayeredNavigation::layer/filter.phtml"/>
          </block>


          I would suggest using a plugin to modify the render method of "MagentoLayeredNavigationBlockNavigationFilterRenderer" if you want to set a default filter.






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38302097%2fmagento2-custom-product-collection-with-layered-navigation%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            The XML you need can be found in Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml



            The snippet you'll need to add to your referenceContainer is:



            <block class="MagentoLayeredNavigationBlockNavigationCategory" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::layer/view.phtml">
            <block class="MagentoLayeredNavigationBlockNavigationState" name="catalog.navigation.state" as="state" />
            <block class="MagentoLayeredNavigationBlockNavigationFilterRenderer" name="catalog.navigation.renderer" as="renderer" template="Magento_LayeredNavigation::layer/filter.phtml"/>
            </block>


            I would suggest using a plugin to modify the render method of "MagentoLayeredNavigationBlockNavigationFilterRenderer" if you want to set a default filter.






            share|improve this answer
























              up vote
              0
              down vote













              The XML you need can be found in Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml



              The snippet you'll need to add to your referenceContainer is:



              <block class="MagentoLayeredNavigationBlockNavigationCategory" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::layer/view.phtml">
              <block class="MagentoLayeredNavigationBlockNavigationState" name="catalog.navigation.state" as="state" />
              <block class="MagentoLayeredNavigationBlockNavigationFilterRenderer" name="catalog.navigation.renderer" as="renderer" template="Magento_LayeredNavigation::layer/filter.phtml"/>
              </block>


              I would suggest using a plugin to modify the render method of "MagentoLayeredNavigationBlockNavigationFilterRenderer" if you want to set a default filter.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                The XML you need can be found in Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml



                The snippet you'll need to add to your referenceContainer is:



                <block class="MagentoLayeredNavigationBlockNavigationCategory" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::layer/view.phtml">
                <block class="MagentoLayeredNavigationBlockNavigationState" name="catalog.navigation.state" as="state" />
                <block class="MagentoLayeredNavigationBlockNavigationFilterRenderer" name="catalog.navigation.renderer" as="renderer" template="Magento_LayeredNavigation::layer/filter.phtml"/>
                </block>


                I would suggest using a plugin to modify the render method of "MagentoLayeredNavigationBlockNavigationFilterRenderer" if you want to set a default filter.






                share|improve this answer












                The XML you need can be found in Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml



                The snippet you'll need to add to your referenceContainer is:



                <block class="MagentoLayeredNavigationBlockNavigationCategory" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::layer/view.phtml">
                <block class="MagentoLayeredNavigationBlockNavigationState" name="catalog.navigation.state" as="state" />
                <block class="MagentoLayeredNavigationBlockNavigationFilterRenderer" name="catalog.navigation.renderer" as="renderer" template="Magento_LayeredNavigation::layer/filter.phtml"/>
                </block>


                I would suggest using a plugin to modify the render method of "MagentoLayeredNavigationBlockNavigationFilterRenderer" if you want to set a default filter.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 11:53









                TomS

                8114




                8114



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38302097%2fmagento2-custom-product-collection-with-layered-navigation%23new-answer', 'question_page');

                    );

                    Post as a guest














































































                    這個網誌中的熱門文章

                    What does pagestruct do in Eviews?

                    Dutch intervention in Lombok and Karangasem

                    Channel Islands