From dbd056ef88cbcb22c34c7ecff68b73a351d76244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Tue, 27 Sep 2016 09:18:28 +0200 Subject: [PATCH] Fix second level category filter --- .../Model/Layer/Filter/Item/Category.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/module-elasticsuite-catalog/Model/Layer/Filter/Item/Category.php b/src/module-elasticsuite-catalog/Model/Layer/Filter/Item/Category.php index 42ff96148..f458c2d4e 100644 --- a/src/module-elasticsuite-catalog/Model/Layer/Filter/Item/Category.php +++ b/src/module-elasticsuite-catalog/Model/Layer/Filter/Item/Category.php @@ -27,16 +27,25 @@ class Category extends \Magento\Catalog\Model\Layer\Filter\Item */ public function getUrl() { - $query = [ - $this->getFilter()->getRequestVar() => $this->getValue(), - $this->_htmlPagerBlock->getPageVarName() => null, + $catRequestVar = $this->getFilter()->getRequestVar(); + $pageRequestVar = $this->_htmlPagerBlock->getPageVarName(); + + $queryParams = [ + $catRequestVar => $this->getValue(), + $pageRequestVar => null, ]; foreach ($this->getFilter()->getLayer()->getState()->getFilters() as $currentFilterItem) { - $query[$currentFilterItem->getFilter()->getRequestVar()] = null; + $currentRequestVar = $currentFilterItem->getFilter()->getRequestVar(); + if ($currentRequestVar != $catRequestVar) { + $queryParams[$currentRequestVar] = null; + } } - $url = $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]); + $url = $this->_url->getUrl( + '*/*/*', + ['_current' => true, '_use_rewrite' => true, '_query' => $queryParams] + ); if ($this->getUrlRewrite()) { $url = $this->getUrlRewrite();