From 274276742a3145a4eeaae43a2b748154b64f2677 Mon Sep 17 00:00:00 2001 From: Robert Saternus Date: Thu, 21 Nov 2024 12:40:55 +0100 Subject: [PATCH] FFWEB-3227: Add the ability to set a name for the CategoryPath field Add the ability to set a name for the CategoryPath field (category page) --- .php-cs-fixer.dist.php | 54 +++++++++---------- CHANGELOG.md | 4 ++ README.md | 13 +++++ src/Resources/config/services.xml | 1 - .../block/cms-block-listing.html.twig | 5 +- 5 files changed, 48 insertions(+), 29 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index e1f1d9f1..f38c2f0a 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -19,31 +19,31 @@ ->setHideProgress(true) ->setUsingCache(false) ->setRules([ - '@PSR2' => true, - '@PSR12' => true, - '@PHP74Migration:risky' => true, - '@Symfony' => true, - 'array_syntax' => ['syntax' => 'short'], - 'binary_operator_spaces' => [ - 'operators' => [ - '=' => 'align', - '=>' => 'align', - ], - ], - 'blank_line_after_opening_tag' => true, - 'line_ending' => true, - 'class_attributes_separation' => false, - 'blank_line_before_statement' => ['statements' => ['break', 'continue', 'declare', 'throw', 'try']], - 'concat_space' => ['spacing' => 'one'], - 'declare_strict_types' => true, - 'increment_style' => ['style' => 'post'], - 'no_superfluous_phpdoc_tags' => false, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'ordered_class_elements' => true, - 'ordered_imports' => ['imports_order' => ['class', 'function', 'const']], - 'strict_comparison' => true, - 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], - 'nullable_type_declaration_for_default_null_value' => false, - ]) + '@PSR2' => true, + '@PSR12' => true, + '@PHP74Migration:risky' => true, + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + 'binary_operator_spaces' => [ + 'operators' => [ + '=' => 'align', + '=>' => 'align', + ], + ], + 'blank_line_after_opening_tag' => true, + 'line_ending' => true, + 'class_attributes_separation' => false, + 'blank_line_before_statement' => ['statements' => ['break', 'continue', 'declare', 'throw', 'try']], + 'concat_space' => ['spacing' => 'one'], + 'declare_strict_types' => true, + 'increment_style' => ['style' => 'post'], + 'no_superfluous_phpdoc_tags' => false, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_class_elements' => true, + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const']], + 'strict_comparison' => true, + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], + 'nullable_type_declaration_for_default_null_value' => false, + ]) ->setFinder($finder); diff --git a/CHANGELOG.md b/CHANGELOG.md index c7ae33d0..8ffc44e1 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## Unreleased +### Improve +- Add the ability to set a name for the CategoryPath field (category page) + ## [v6.0.0] - 2024.07.12 ### BREAKING - IMPORTANT! Drop Shopware 6.5 compatibility diff --git a/README.md b/README.md index acea2ef0..01358399 100755 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ modifications in order to fit their needs. For more advanced features please che - [Campaigns Element](#campaigns-element) - [Blocks and Elements Templates](#blocks-and-elements-templates) - [Assigning Layout to Category](#assigning-layout-to-category) + - [Set correct name for CategoryPath field](#set-correct-name-for-categorypath-field) - [Exporting Feeds](#exporting-feeds) - [CLI](#cli) - [Selecting Categories for CMS Export](#selecting-categories-for-cms-export) @@ -276,6 +277,15 @@ Once the page layout is done, you need to assign layout to selected categories. We strongly recommend not creating many layouts as currently there's still only few possibilities offered anyway. Future development will bring more blocks and elements will be provided here. +### Set correct name for CategoryPath field + +By default, SDK uses a field named CategoryPath (default field name for FactFinder instance). +If in your FactFinder instance configuration you have a different field name for Category field then you must set this name in the `services.xml` file as shown below: + + //src/Resources/config/services.xml:34 + CategoryPath + + ## Exporting Feeds FACT-Finder allows to export different types of feeds, like a **products**, **cms** and **brands** (or manufacturers) @@ -504,6 +514,9 @@ where `$association` would be a `children.cover` in that example. **Note:** Please note that adding more and more associations will have an impact on overall export performance. +**Note:** +If you need to export variant names in data feed you could use [this sample code as an example](https://github.com/FACT-Finder-Web-Components/shopware6-plugin/pull/258): + ### Creating Custom Entity Export Plugin offers a flexible export mechanism which could be specified to work with different types of entities. diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index b29fd534..296eeed1 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -47,7 +47,6 @@ children.media - CategoryPath 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 3c32344f..5a4b156d 100644 --- a/src/Resources/views/storefront/block/cms-block-listing.html.twig +++ b/src/Resources/views/storefront/block/cms-block-listing.html.twig @@ -7,7 +7,10 @@ document.addEventListener(`ffCoreReady`, ({ factfinder }) => { factfinder.config.setAppConfig({ categoryPage: [ - factfinder.utils.filterBuilders.categoryFilter(`CategoryPath`, {{ (page.extensions.factfinder.communication.categoryPage|split(',')|json_encode())|raw }}) + factfinder.utils.filterBuilders.categoryFilter( + '{{ page.extensions.factfinder.categoryPathFieldName|replace({'ROOT': ''}) }}', + {{ (page.extensions.factfinder.communication.categoryPage|split(',')|json_encode())|raw }} + ) ], });