From 119d3c78c85d5a4371dc258d856b89fe57268a74 Mon Sep 17 00:00:00 2001 From: Robert Saternus Date: Thu, 25 Jul 2024 09:52:41 +0200 Subject: [PATCH] FFWEB-3121: New category pages NG implementation New category pages NG implementation --- spec/Subscriber/CategoryPageSubscriberSpec.php | 6 +++--- .../storefront/block/cms-block-listing.html.twig | 16 +++++++++++++++- .../storefront/page/factfinder/result.html.twig | 2 +- src/Subscriber/CategoryPageSubscriber.php | 2 +- src/Utilites/Ssr/Field/CategoryPath.php | 10 +--------- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/spec/Subscriber/CategoryPageSubscriberSpec.php b/spec/Subscriber/CategoryPageSubscriberSpec.php index 264ad456..9c2302f3 100644 --- a/spec/Subscriber/CategoryPageSubscriberSpec.php +++ b/spec/Subscriber/CategoryPageSubscriberSpec.php @@ -22,7 +22,7 @@ class CategoryPageSubscriberSpec extends ObjectBehavior { - private string $filterCategoryPath = 'filter=CategoryPath%3ABooks+%252B+Sports%2FHome+%252F+Garden+100%2525'; + private string $filterCategoryPath = 'Books + Sports,Home / Garden 100%'; public function let( AbstractCategoryRoute $cmsPageRoute, @@ -47,7 +47,7 @@ public function it_should_add_category_page_attribute_in_category_config( NavigationPageLoadedEvent $event ): void { $categoryEntity->getCustomFields()->willReturn([OmikronFactFinder::DISABLE_SEARCH_IMMEDIATE_CUSTOM_FIELD_NAME => false]); - $extension->assign(Argument::withEntry('communication', Argument::withEntry('category-page', Argument::any())))->shouldBeCalled(); + $extension->assign(Argument::withEntry('communication', Argument::withEntry('categoryPage', Argument::any())))->shouldBeCalled(); $this->onPageLoaded($event); } @@ -77,7 +77,7 @@ public function it_should_encode_category_path_correctly( ArrayEntity $extension, NavigationPageLoadedEvent $event ): void { - $extension->assign(Argument::withEntry('communication', Argument::withEntry('category-page', $this->filterCategoryPath)))->shouldBeCalled(); + $extension->assign(Argument::withEntry('communication', Argument::withEntry('categoryPage', $this->filterCategoryPath)))->shouldBeCalled(); $this->onPageLoaded($event); } diff --git a/src/Resources/views/storefront/block/cms-block-listing.html.twig b/src/Resources/views/storefront/block/cms-block-listing.html.twig index e840afb7..edc790a0 100644 --- a/src/Resources/views/storefront/block/cms-block-listing.html.twig +++ b/src/Resources/views/storefront/block/cms-block-listing.html.twig @@ -1,6 +1,20 @@ {% block block_factfinder_web_components_listing %} {% set columns = 1 %} {% set element = block.slots.getSlot('toolbarFilters') %} + + + +
{% block element_product_listing_filter_button %} @@ -27,7 +41,7 @@
-
+
diff --git a/src/Resources/views/storefront/page/factfinder/result.html.twig b/src/Resources/views/storefront/page/factfinder/result.html.twig index 7fa8e2d3..d9f32eaa 100644 --- a/src/Resources/views/storefront/page/factfinder/result.html.twig +++ b/src/Resources/views/storefront/page/factfinder/result.html.twig @@ -52,7 +52,7 @@
-
+
{% sw_include '@Parent/storefront/components/factfinder/toolbar.html.twig' %} {% sw_include '@Parent/storefront/components/factfinder/record-list.html.twig' with { subscribe: true, class: 'row cms-listing-row', ssr: page.extensions.factfinder.ssr } %} diff --git a/src/Subscriber/CategoryPageSubscriber.php b/src/Subscriber/CategoryPageSubscriber.php index 345d53bb..c50e6ee5 100755 --- a/src/Subscriber/CategoryPageSubscriber.php +++ b/src/Subscriber/CategoryPageSubscriber.php @@ -59,7 +59,7 @@ public function onPageLoaded(NavigationPageLoadedEvent $event): void $categoryPath = (new CategoryPath($this->fieldName))->getValue($category); $communication = [ 'add-params' => implode(',', array_map(fn (string $key, string $value): string => sprintf('%s=%s', $key, $value), array_keys($mergedAddParams), array_values($mergedAddParams))), - ] + ($isCategory ? ['category-page' => $categoryPath] : []); + ] + ($isCategory ? ['categoryPage' => $categoryPath] : []); if ($route === 'frontend.navigation.page') { $event->getRequest()->attributes->set('categoryPath', $categoryPath); diff --git a/src/Utilites/Ssr/Field/CategoryPath.php b/src/Utilites/Ssr/Field/CategoryPath.php index b9f1cc3f..6c9ebc4d 100644 --- a/src/Utilites/Ssr/Field/CategoryPath.php +++ b/src/Utilites/Ssr/Field/CategoryPath.php @@ -18,15 +18,7 @@ public function __construct(string $categoryPathFieldName) public function getValue(CategoryEntity $categoryEntity): string { $categories = array_slice($categoryEntity->getBreadcrumb(), 1); - $categoryPath = implode('/', array_map(fn ($category): string => $this->encodeCategoryName($category), $categories)); - return sprintf('filter=%s', urlencode($this->fieldName . ':' . $categoryPath)); - } - - private function encodeCategoryName(string $path): string - { - // important! do not modify this method - return preg_replace('/\+/', '%2B', preg_replace('/\//', '%2F', - preg_replace('/%/', '%25', $path))); + return implode(',', $categories); } }