I'm creating a custom brand page in which are listed product with a specific brand.
I've created a static page with a 2 column layout, with a left sidebar in which I'm putting filters and the main column contains the products grid.
This is the code for the content widget
{{widget type="Magento\CatalogWidget\Block\Product\ProductsList"
show_pager="0"
products_count="100"
tagline="bla bla bla."
logo="pub/media/brands/brand.png"
template="MyVendor_MyTheme::product/widget/content/grid.phtml"
conditions_encoded="^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`,`aggregator`:`all`,`value`:`1`,`new_child`:``^],`1--1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Product`,`attribute`:`brand`,`operator`:`==`,`value`:`3847`^]^]"}}
for which I've overridden the Magento template grid.phtml
In the left sidebar I've put layered navigation
<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>
for which I'm overriding the view.phtml template. I'm able to start with a filtered collection in the view.phtml like this
$block->getLayer()->getProductCollection()->addFieldToFilter('brand','3847')
and filters returns the correct item count inside the block.
I've added a:
$block->getProductCollection()->addFieldToFilter('brand','3847')
in the grid.phtml just for debugging and the collection is correct in the grid.phtml template
The problem is that the filter is not applied to the grid.phtml block.
How do I "connect" the two blocks?