diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f38c2f0a..b7854725 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -21,7 +21,7 @@ ->setRules([ '@PSR2' => true, '@PSR12' => true, - '@PHP74Migration:risky' => true, + '@PHP7x4Migration:risky' => true, '@Symfony' => true, 'array_syntax' => ['syntax' => 'short'], 'binary_operator_spaces' => [ diff --git a/CHANGELOG.md b/CHANGELOG.md index e2600290..abda9c63 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog ## Unreleased +### Add +- Add possibility to disable Web Components integration per sales channel + ### Change - Upgrade Web Components version to v5.1.7 - Add template to suggest element diff --git a/README.md b/README.md index cb75f85b..9e3ff645 100755 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ store cache in order the new applied configuration to start working. * Server URL - FACT-Finder® instance url **Note:** Server URL should contain a used protocol: (e.g. `https://`) and should end with an endpoint ( `fact-finder` ) -* Channel - Channel you want to serve data from +* Channel - Channel you want to serve data from. This field works for each sales channel separately, so you can, for example, adjust FactFinder integration to different store's language versions. * API key - your FACT-Finder® API key You can check if the above data is correctly set by clicking on the `Test Connection` button. Please save your settings before clicking on button. @@ -123,6 +123,13 @@ You can find more information about what Field Roles are in (Web Components docu **Note:** Updating process is ran for all sales channels, no need to run it separately for each of them +#### Disable FactFinder Web Components option + +This option allows you to disable FACT-Finder® Web Components integration on the frontend. It works for each sales channel separately so you can use our plugin only on the sales channels you want. + +**Note:** If you enable this option, FACT-Finder® integration on the frontend will stop working. Pay special attention not to define FACT-Finder® category pages for sales channels where you enable this option, as this will cause an error on the page or incorrect generation of HTML code + + ## Advanced Settings ![Advanced Settings](docs/assets/advanced-settings.png "Advanced Settings") @@ -462,6 +469,17 @@ Plugin implements a list of given Web Components: * ff-checkout-tracking +## Sales channels management + +The entire plugin configuration must be placed in `All Sales Channels`: + +![sales-channels-management.png](docs/assets/sales-channels-management.png) + +There are only two fields that can be defined for each sales channel separately: + +- `Channel` - you can define different data comes from FACT-Finder®, especially in the case of multi-language stores +- `Disable FactFinder Web Components on frontend?` - allows you to disable FACT-Finder® Web Components integration on the frontend. With this option you can use our plugin only on the sales channels you want. + ## Modifications Examples ### Adding New Column to Feed diff --git a/docs/assets/advanced-settings.png b/docs/assets/advanced-settings.png index 717ba4c8..3b0f3d6e 100644 Binary files a/docs/assets/advanced-settings.png and b/docs/assets/advanced-settings.png differ diff --git a/docs/assets/sales-channels-management.png b/docs/assets/sales-channels-management.png new file mode 100644 index 00000000..6f70e318 Binary files /dev/null and b/docs/assets/sales-channels-management.png differ diff --git a/spec/Storefront/Controller/ResultControllerSpec.php b/spec/Storefront/Controller/ResultControllerSpec.php index 190134b1..4e878c74 100644 --- a/spec/Storefront/Controller/ResultControllerSpec.php +++ b/spec/Storefront/Controller/ResultControllerSpec.php @@ -67,6 +67,7 @@ public function let( $this->factfinderLogger = $factfinderLogger; $this->beConstructedWith($config, $pageLoader, $factfinderLogger); $requestStack->getCurrentRequest()->willReturn($request); + $salesChannelContext->getSalesChannelId()->willReturn('main_sales_channel'); $container->get('request_stack')->willReturn($requestStack); $this->request->attributes = $attributes; $attributes->get(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT)->willReturn($salesChannelContext); @@ -93,6 +94,7 @@ public function it_should_return_original_response_content_when_ssr_is_not_activ $this->twig->render('@OmikronFactFinder/storefront/page/factfinder/result.html.twig', Argument::any())->willReturn($content); $this->seoUrlPlaceholderHandler->replace($content, 'https://shop.com', $this->salesChannelContext)->willReturn($content); $this->mediaUrlPlaceholderHandler->replace($content)->willReturn($content); + $this->config->disableFFWebc('main_sales_channel')->willReturn(false); $response = $this->result( $this->request, $this->salesChannelContext, diff --git a/src/Config/Communication.php b/src/Config/Communication.php index e792a0e8..20372367 100644 --- a/src/Config/Communication.php +++ b/src/Config/Communication.php @@ -18,6 +18,11 @@ public function getChannel(?string $salesChannelId = null): string return (string) $this->config('channel', $salesChannelId); } + public function disableFFWebc(?string $salesChannelId = null): bool + { + return (bool) $this->config('disableFactFinderWebc', $salesChannelId); + } + public function getCredentials(): array { return [ diff --git a/src/Domain/RedirectMapping.php b/src/Domain/RedirectMapping.php index 75854b96..a5683142 100644 --- a/src/Domain/RedirectMapping.php +++ b/src/Domain/RedirectMapping.php @@ -4,7 +4,7 @@ namespace Omikron\FactFinder\Shopware6\Domain; -readonly class RedirectMapping +readonly class RedirectMapping implements \Stringable { public function __construct(private string $data) { diff --git a/src/Export/Field/PriceCurrency.php b/src/Export/Field/PriceCurrency.php index 34b8943a..553002c3 100644 --- a/src/Export/Field/PriceCurrency.php +++ b/src/Export/Field/PriceCurrency.php @@ -9,7 +9,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\Entity; use Shopware\Core\System\Currency\CurrencyEntity; -class PriceCurrency extends Price +class PriceCurrency extends Price implements \Stringable { private CurrencyEntity $currency; private NumberFormatter $numberFormatter; diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml index 9cbb4466..6598f33d 100644 --- a/src/Resources/config/config.xml +++ b/src/Resources/config/config.xml @@ -54,6 +54,15 @@ Diese Option funktioniert nur, wenn das serverseitige Rendering [SSR] aktiviert ist. Wenn das SSR-Suchergebnis ein Ergebnis enthält, wird es automatisch auf die Produktdetailseite umgeleitet [PDP]. + + disableFactFinderWebc + + + false + You can disable FactFinder integration on the frontend. This option works for each sales channel separately. Note. If you enable this option, FactFinder integration on the frontend will stop working. + Sie können die FactFinder-Integration im Frontend deaktivieren. Diese Option funktioniert für jeden Vertriebskanal separat. Notiz. Wenn Sie diese Option aktivieren, funktioniert die FactFinder-Integration im Frontend nicht mehr. + + useProxy diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index f0153e12..dc677f45 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -213,5 +213,10 @@ + + + + + diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index 7d43ea20..b7056f3d 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -1,149 +1,153 @@ {% sw_extends '@Parent/storefront/base.html.twig' %} {% block base_body_inner %} - {% block base_body_inner_factfinder_communication %} - - - + return false; + }); + {% endif %} + + {% if page.extensions.factfinder.searchImmediate and not page.extensions.factfinder.ssr %} + const searchParams = factfinder.utils.env.searchParamsFromUrl( + { categoryFieldName: `{{ page.extensions.factfinder.categoryPathFieldName }}` } + ); + initialSearch(searchParams, { requestOptions: { origin: `initialSearch` } }); + {% endif %} + + }); + - {% endblock %} + {% endblock %} + {% endif %} {{ parent() }} {% endblock %} {% block base_body_script %} - + + {% if page.extensions.factfinder.ssr %} + if (!ffCookies['ffwebc_sid']) { + const sid = generateSid(); + document.cookie = 'ffwebc_sid=' + sid + '; path=/;'; + factfinder.config.setFFParams({sid: sid}); + } else { + factfinder.config.setFFParams({sid: ffCookies['ffwebc_sid']}); + } + {% endif %} + }); + + {% endif %} {{ parent() }} {% endblock %} diff --git a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig index 86f3af13..3d1f708e 100644 --- a/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig +++ b/src/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig @@ -2,5 +2,7 @@ {% block buy_widget_product_buy_meta %} {{ parent() }} - + {% if not ff_disable_webc() %} + + {% endif %} {% endblock %} diff --git a/src/Resources/views/storefront/component/product/card/action.html.twig b/src/Resources/views/storefront/component/product/card/action.html.twig index 9972370b..fff487e8 100644 --- a/src/Resources/views/storefront/component/product/card/action.html.twig +++ b/src/Resources/views/storefront/component/product/card/action.html.twig @@ -2,5 +2,7 @@ {% block page_product_detail_product_buy_meta %} {{ parent() }} - + {% if not ff_disable_webc() %} + + {% endif %} {% endblock %} diff --git a/src/Resources/views/storefront/element/cms-element-product-description-reviews.html.twig b/src/Resources/views/storefront/element/cms-element-product-description-reviews.html.twig index 1f1ec8c3..1c450e50 100644 --- a/src/Resources/views/storefront/element/cms-element-product-description-reviews.html.twig +++ b/src/Resources/views/storefront/element/cms-element-product-description-reviews.html.twig @@ -15,25 +15,28 @@ } } %} {{ parent() }} -
- {% if page.extensions.factfinder.features.useRecommendations %} - {% sw_include '@Parent/storefront/components/factfinder/recommendation.html.twig' %} - {% endif %} + {% if not ff_disable_webc() %} +
- {% if page.extensions.factfinder.features.useSimilarProducts %} - {% sw_include '@Parent/storefront/components/factfinder/similar-products.html.twig' %} - {% endif %} + {% if page.extensions.factfinder.features.useRecommendations %} + {% sw_include '@Parent/storefront/components/factfinder/recommendation.html.twig' %} + {% endif %} - {% if page.extensions.factfinder.features.useProductCampaigns %} - {% sw_include '@Parent/storefront/components/factfinder/campaign-product.html.twig' %} - {% sw_include '@Parent/storefront/components/factfinder/campaign-feedbacktext.html.twig' with { flag: 'is-product-campaign' } %} - {% sw_include '@Parent/storefront/components/factfinder/campaign-pushed-products.html.twig' with { - recordListTemplate: '@Parent/storefront/components/factfinder/record-list-slider.html.twig', - origin: 'ff-campaign-pushed-products', - flag: 'is-product-campaign' - } %} - {% endif %} + {% if page.extensions.factfinder.features.useSimilarProducts %} + {% sw_include '@Parent/storefront/components/factfinder/similar-products.html.twig' %} + {% endif %} -
+ {% if page.extensions.factfinder.features.useProductCampaigns %} + {% sw_include '@Parent/storefront/components/factfinder/campaign-product.html.twig' %} + {% sw_include '@Parent/storefront/components/factfinder/campaign-feedbacktext.html.twig' with { flag: 'is-product-campaign' } %} + {% sw_include '@Parent/storefront/components/factfinder/campaign-pushed-products.html.twig' with { + recordListTemplate: '@Parent/storefront/components/factfinder/record-list-slider.html.twig', + origin: 'ff-campaign-pushed-products', + flag: 'is-product-campaign' + } %} + {% endif %} + +
+ {% endif %} {% endblock %} diff --git a/src/Resources/views/storefront/layout/header/search.html.twig b/src/Resources/views/storefront/layout/header/search.html.twig index 421aeb95..913d1d52 100644 --- a/src/Resources/views/storefront/layout/header/search.html.twig +++ b/src/Resources/views/storefront/layout/header/search.html.twig @@ -1,32 +1,57 @@ {% sw_extends '@Parent/storefront/layout/header/search.html.twig' %} + {% block layout_header_search %} -
-