I'm going to write a block to put in products list page. My question is how can I get to know which layered navigation filters are currently applied in the current list page ?

Any help will be appreciated.

  • any helps ????? Aug 5 '16 at 5:30
  • Hi michel Gokan did u implement this concept in magento 2 api level? Mar 14 '18 at 7:00
  • @NagarajuKasa Did you try Giel's solution below? I asked this question about 2 years ago and I'm not working with Magento anymore but his solution works like a charm on that time. However, Magento evolved too much and I was working with 2.1 version. Mar 14 '18 at 11:09
  • thanks for your comments @michel, may i know whether the below concept will work for an API level? do u have any idea thanks Mar 14 '18 at 11:17
  • Please find the below link , i need to implement an api for magento 2 magento.stackexchange.com/questions/217261/… Mar 14 '18 at 11:17

You can do this with the layer resolver (Magento\Catalog\Model\Layer\Resolver). Example code:

public function __construct(
    \Magento\Catalog\Model\Layer\Resolver $layerResolver
    $this->layerResolver = $layerResolver;
    $layer = $this->layerResolver->get();
    $activeFilters = $layer->getState()->getFilters();


A small sidenote to those who might concern: you can only get the state after \Magento\Catalog\Controller\Category\View::execute() has already created the state. Otherwise you get a Catalog Layer has been already created runtime exception.


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.