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" 
tagline="bla bla bla."  

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"/>


for which I'm overriding the view.phtml template. I'm able to start with a filtered collection in the view.phtml like this


and filters returns the correct item count inside the block.

I've added a:


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?

2 Answers 2


The source of your problem is that LayeredNavigation module uses it's own product collection.

namespace Vendor\Module\Controller\Index;    

use Magento\Framework\App\Action\Action;

class Index extends Action
    /** @var \Magento\Framework\App\Action\Context
    protected $context;

    /** @var \Magento\Framework\View\Result\PageFactory */
    protected $pageFactory;

    /** @var \Magento\Catalog\Model\Layer\Resolver */
    protected $layerResolver;

    public function __construct(
        Context $context,
        PageFactory $pageFactory,
        Resolver $layerResolver
    ) {
        $this->layerResolver = $layerResolver;
        $this->pageFactory = $pageFactory;
        $this->context = $context;

    public function execute()
        $result = $this->pageFactory->create();
        $collection = $this->layerResolver->get()->getProductCollection()->addFieldToFilter('brand','3847');
        $list = $result->getLayout()->getBlock('category.products.list');
        return $result;
  • yeah this is the problem i have and i already know about it. I need a solution ;)
    – sissy
    Commented Jun 5, 2018 at 9:04
  • To code i posted will make your product listing to have the same collection as layeredNavigation has.
    – embed0
    Commented Jun 8, 2018 at 7:25

The easiest way I can think of is to simply create (either manually of programmatically) categories for your brands and to use a cron task to assign / deassign your products to those categories based on the value of their brand attribute. This way you can let Magento do the frontend work for you.

  • I don't think it would be a feasible solution. The catalog product is pretty big (45000 products more or less) and it is heavily modified on a daily basis and moreover, the people who manages the Magento backend are not so expert, so it would be a mess to give them more things to manage. But thank you for your help.
    – sissy
    Commented Jun 7, 2018 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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