From 0c77e700cb16bc736ffdfa9ed7b7650e4138e092 Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Wed, 4 Sep 2024 13:49:06 +0200 Subject: [PATCH 1/5] Add configuration option for Ignore cookie consent --- src/Model/Config/NostoConfigService.php | 2 ++ src/Model/ConfigProvider.php | 9 +++++++++ ...nosto-integration-features-flags.html.twig | 20 +++++++++++++++++++ .../src/module/nosto/snippet/de-DE.json | 2 ++ .../src/module/nosto/snippet/en-GB.json | 2 ++ 5 files changed, 35 insertions(+) diff --git a/src/Model/Config/NostoConfigService.php b/src/Model/Config/NostoConfigService.php index 7e567d94..5f644982 100644 --- a/src/Model/Config/NostoConfigService.php +++ b/src/Model/Config/NostoConfigService.php @@ -80,6 +80,8 @@ class NostoConfigService public const ENABLE_STORE_ABANDONED_CART_DATA = 'storeAbandonedCartData'; + public const ENABLE_IGNORE_COOKIE_CONSENT = 'ignoreCookieConsent'; + public const DAILY_PRODUCT_SYNC_ENABLED = 'dailySynchronization'; public const DAILY_PRODUCT_SYNC_TIME = 'dailySynchronizationTime'; diff --git a/src/Model/ConfigProvider.php b/src/Model/ConfigProvider.php index 5ebc7b26..739b0497 100644 --- a/src/Model/ConfigProvider.php +++ b/src/Model/ConfigProvider.php @@ -218,6 +218,15 @@ public function isEnabledReloadRecommendationsAfterAdding( ); } + public function isEnabledIgnoreCookieConsent($channelId = null, $languageId = null): bool + { + return $this->configService->getBool( + NostoConfigService::ENABLE_IGNORE_COOKIE_CONSENT, + $channelId, + $languageId + ); + } + public function isEnabledProductLabellingSync(?string $channelId = null, ?string $languageId = null): bool { return $this->configService->getBool( diff --git a/src/Resources/app/administration/src/module/nosto/components/nosto-integration-features-flags/nosto-integration-features-flags.html.twig b/src/Resources/app/administration/src/module/nosto/components/nosto-integration-features-flags/nosto-integration-features-flags.html.twig index a5cb3860..c98cb084 100644 --- a/src/Resources/app/administration/src/module/nosto/components/nosto-integration-features-flags/nosto-integration-features-flags.html.twig +++ b/src/Resources/app/administration/src/module/nosto/components/nosto-integration-features-flags/nosto-integration-features-flags.html.twig @@ -348,6 +348,26 @@ {% endblock %} + {% block nosto_integration_feature_ignore_cookie_consent %} + + + + {% endblock %} + {% block nosto_integration_daily_synchronization_flag %} Date: Thu, 5 Sep 2024 12:52:16 +0200 Subject: [PATCH 2/5] Add check for nosto cookie --- src/Subscriber/FrontendSubscriber.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Subscriber/FrontendSubscriber.php b/src/Subscriber/FrontendSubscriber.php index 6c144f91..674f527b 100644 --- a/src/Subscriber/FrontendSubscriber.php +++ b/src/Subscriber/FrontendSubscriber.php @@ -46,7 +46,7 @@ public function onHeaderLoaded(HeaderPageletLoadedEvent $event): void public function onKernelResponse(ResponseEvent $event): void { - if (!($event->getResponse() instanceof StorefrontResponse)) { + if (!($event->getResponse())) { return; } @@ -59,7 +59,10 @@ public function onKernelResponse(ResponseEvent $event): void private function migrateOverdoseCookie(Response $response, Request $request): void { - if ($request->cookies->has(NostoCookieProvider::LEGACY_COOKIE_KEY)) { + if ( + $request->cookies->has(NostoCookieProvider::LEGACY_COOKIE_KEY) || + $this->configProvider->isEnabledIgnoreCookieConsent() + ) { $cookie = Cookie::create(NostoCookieProvider::LEGACY_COOKIE_KEY, '1', strtotime('-1 day')) ->withHttpOnly(false); $cookie->setSecureDefault($request->isSecure()); From 5dc997d6ea0fb2b7ed0d86ced91abec0b12819c6 Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Thu, 5 Sep 2024 12:57:38 +0200 Subject: [PATCH 3/5] Correct the changes --- src/Model/ConfigProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/ConfigProvider.php b/src/Model/ConfigProvider.php index 739b0497..176a1db5 100644 --- a/src/Model/ConfigProvider.php +++ b/src/Model/ConfigProvider.php @@ -223,7 +223,7 @@ public function isEnabledIgnoreCookieConsent($channelId = null, $languageId = nu return $this->configService->getBool( NostoConfigService::ENABLE_IGNORE_COOKIE_CONSENT, $channelId, - $languageId + $languageId, ); } From c36d8473d3715465f0e11de911879e88b6bfe107 Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Thu, 5 Sep 2024 13:01:08 +0200 Subject: [PATCH 4/5] Correct the changes --- src/Subscriber/FrontendSubscriber.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Subscriber/FrontendSubscriber.php b/src/Subscriber/FrontendSubscriber.php index 674f527b..878fba39 100644 --- a/src/Subscriber/FrontendSubscriber.php +++ b/src/Subscriber/FrontendSubscriber.php @@ -7,7 +7,6 @@ use Nosto\NostoIntegration\Decorator\Storefront\Framework\Cookie\NostoCookieProvider; use Nosto\NostoIntegration\Model\ConfigProvider; use Nosto\NostoIntegration\Struct\Config; -use Shopware\Storefront\Framework\Routing\StorefrontResponse; use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Cookie; From 8ac6e19174e2f0ca5846a33ab9d90fdbbbbe44e2 Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Mon, 9 Sep 2024 16:44:18 +0200 Subject: [PATCH 5/5] Correct the help text --- .../app/administration/src/module/nosto/snippet/de-DE.json | 2 +- .../app/administration/src/module/nosto/snippet/en-GB.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/app/administration/src/module/nosto/snippet/de-DE.json b/src/Resources/app/administration/src/module/nosto/snippet/de-DE.json index 8ab3a0c9..70ade2b9 100644 --- a/src/Resources/app/administration/src/module/nosto/snippet/de-DE.json +++ b/src/Resources/app/administration/src/module/nosto/snippet/de-DE.json @@ -109,7 +109,7 @@ "enableReloadRecommendationsHelpText": "Wenn das Kontrollkästchen aktiviert ist, werden die Empfehlungen nach dem Hinzufügen eines empfohlenen Produkts neu geladen", "enableLabellingHelpText": "Wenn das Kontrollkästchen aktiviert ist, werden die Produktetiketten an Nosto gesendet.", "storeAbandonedCartDataHelpText": "Diese Konfigurationsoption steuert, ob Daten für abgebrochene Warenkörbe in der entsprechenden Datenbank Tabelle gespeichert werden sollen. Wenn diese Option aktiviert ist, ruft das System die Daten ab und erstellt neue Zeilen in der Tabelle für jeden abgebrochenen Warenkorb. Wenn sie deaktiviert ist, werden keine neuen Zeilen hinzugefügt, was möglicherweise Leistungsprobleme verhindert.", - "ignoreCookieConsentHelpText": "Wenn das Kontrollkästchen aktiviert ist, werden die Cookies für Nosto automatisch akzeptiert", + "ignoreCookieConsentHelpText": "Die Zustimmung zu Cookies kann deaktiviert werden, wenn Sie bestimmen, dass sie für die rechtliche Einhaltung nicht erforderlich ist.", "categoryNamingHelpText": "Produktkategorienamen enthalten die Kategorie-ID oder nicht", "categoryNaming": "Produktkategorienamen", "categoryBlocklist": "Kategorie Ausschluss", diff --git a/src/Resources/app/administration/src/module/nosto/snippet/en-GB.json b/src/Resources/app/administration/src/module/nosto/snippet/en-GB.json index 67bff2e8..4ca1460b 100644 --- a/src/Resources/app/administration/src/module/nosto/snippet/en-GB.json +++ b/src/Resources/app/administration/src/module/nosto/snippet/en-GB.json @@ -109,7 +109,7 @@ "enableReloadRecommendationsHelpText": "If the checkbox is checked, the recommendations will be reloaded after adding a recommended product", "enableLabellingHelpText": "If the checkbox is checked, product labels will be sent to Nosto", "storeAbandonedCartDataHelpText": "This configuration option controls whether data for abandoned carts should be stored in the relevant table. When this option is enabled, the system will fetch and create new rows in the table for each abandoned cart. If disabled, no new rows will be added, potentially preventing performance issues.", - "ignoreCookieConsentHelpText": "If the checkbox is checked, cookies for Nosto will be automatically accepted", + "ignoreCookieConsentHelpText": "Cookie consent may be turned off if you determine it is not required for legal compliance.", "categoryNamingHelpText": "Product category names will contain the category ID or not", "categoryNaming": "Product Category Names", "categoryBlocklist": "Category Exclusion",