From 63bbb80b3b340619594884a27149b3fbd60e77e2 Mon Sep 17 00:00:00 2001 From: Herant Date: Fri, 5 Nov 2021 11:10:41 +0100 Subject: [PATCH 1/2] Reset the pagination in query if a filter has been chosen --- .../LayeredNavigation/RenderLayered/AnchorRendererTrait.php | 2 +- Model/NavigationConfig.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php b/Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php index e6a8bf1c..d5b36577 100644 --- a/Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php +++ b/Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php @@ -36,7 +36,7 @@ public function renderAnchorHtmlTagAttributes(Item $item) */ protected function getAnchorTagAttributes(Item $item): array { - $itemUrl = $this->getItemUrl($item); + $itemUrl = preg_replace('/&p=(.*?.)/', '', $this->getItemUrl($item)); if ($this->filterHelper->shouldFilterBeIndexable($item)) { return ['href' => $itemUrl]; } diff --git a/Model/NavigationConfig.php b/Model/NavigationConfig.php index caab2483..046a6744 100644 --- a/Model/NavigationConfig.php +++ b/Model/NavigationConfig.php @@ -94,7 +94,10 @@ public function __construct( */ public function getFilterFormInput(): array { - return $this->filterFormInputProvider->getFilterFormInput(); + $filterFormInput = $this->filterFormInputProvider->getFilterFormInput(); + unset($filterFormInput['p']); + + return $filterFormInput; } /** From fe8f32df4eefb5fbd8163b5ab1e3368d08efd9ad Mon Sep 17 00:00:00 2001 From: Herant Date: Fri, 5 Nov 2021 13:57:19 +0100 Subject: [PATCH 2/2] Update regex accordingly --- Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php b/Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php index d5b36577..18dd9851 100644 --- a/Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php +++ b/Block/LayeredNavigation/RenderLayered/AnchorRendererTrait.php @@ -36,7 +36,7 @@ public function renderAnchorHtmlTagAttributes(Item $item) */ protected function getAnchorTagAttributes(Item $item): array { - $itemUrl = preg_replace('/&p=(.*?.)/', '', $this->getItemUrl($item)); + $itemUrl = preg_replace('/&p=\d+/', '', $this->getItemUrl($item)); if ($this->filterHelper->shouldFilterBeIndexable($item)) { return ['href' => $itemUrl]; }