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.
blockslayered-navigationmagento-2.1magento2product-list
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.
Best Answer
You can do this with the layer resolver (
Magento\Catalog\Model\Layer\Resolver
). Example code:Edit:
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 aCatalog Layer has been already created
runtime exception.