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.
- What do i need to insert into xml layout to display layered navigation block ?
<referenceContainer name="sidebar.main">
<!-- ??? -->
</referenceContainer>
- 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
add a comment |
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.
- What do i need to insert into xml layout to display layered navigation block ?
<referenceContainer name="sidebar.main">
<!-- ??? -->
</referenceContainer>
- 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
add a comment |
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.
- What do i need to insert into xml layout to display layered navigation block ?
<referenceContainer name="sidebar.main">
<!-- ??? -->
</referenceContainer>
- 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
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.
- What do i need to insert into xml layout to display layered navigation block ?
<referenceContainer name="sidebar.main">
<!-- ??? -->
</referenceContainer>
- 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
magento2
asked Jul 11 '16 at 8:12
kaspi
464
464
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 10 at 11:53
TomS
8114
8114
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password