Skip to content

Commit

Permalink
Merge pull request #80 from Nosto/SSP-98_cookie_consent_configuration_v4
Browse files Browse the repository at this point in the history
SSP-98 Cookie Consent Configuration v4
  • Loading branch information
iganulevics authored Sep 10, 2024
2 parents 482e8f4 + 8ac6e19 commit cf7738a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Model/Config/NostoConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
9 changes: 9 additions & 0 deletions src/Model/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,26 @@
</sw-inherit-wrapper>
{% endblock %}

{% block nosto_integration_feature_ignore_cookie_consent %}
<sw-inherit-wrapper
:value="currentConfig['ignoreCookieConsent']"
:inheritedValue="configKey === null ? null : configs['null']['ignoreCookieConsent']"
@update:value="onUpdateValue('ignoreCookieConsent', $event)"
>
<template #content="props">
<sw-switch-field
name="ignoreCookieConsent"
:map-inheritance="props"
:label="$tc('nosto.configuration.featuresFlags.ignoreCookieConsent')"
:help-text="$tc('nosto.configuration.featuresFlags.ignoreCookieConsentHelpText')"
:disabled="props.isInherited"
:value="props.currentValue"
@update:value="onUpdateValue('ignoreCookieConsent', $event)"
/>
</template>
</sw-inherit-wrapper>
{% endblock %}

{% block nosto_integration_daily_synchronization_flag %}
<sw-inherit-wrapper
v-if="configKey === null"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"enableReloadRecommendations": "Empfehlungen neu laden, nachdem ein empfohlenes Produkt hinzugefügt wurde",
"enableLabelling": "Synchronisierung der Produktkennzeichnung aktivieren",
"storeAbandonedCartData": "Datenspeicherung für abgebrochene Warenkörbe",
"ignoreCookieConsent": "Cookie-Zustimmung ignorieren",
"enableDailySynchronization": "Tägliche Produktsynchronisierung aktivieren",
"enableDailySynchronizationHelp": "Wenn das Feld aktiviert ist, werden die Produkte jeden Tag zur angegebenen Zeit synchronisiert",
"timeDailySynchronization": "Zeit für die tägliche Produktsynchronisierung",
Expand All @@ -108,6 +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": "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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"enableReloadRecommendations": "Reload Recommendations After Adding a recommended product",
"enableLabelling": "Enable Product Labelling Sync",
"storeAbandonedCartData": "Store data for abandoned carts",
"ignoreCookieConsent": "Ignore cookie consent",
"enableDailySynchronization": "Enable Daily Product Synchronization",
"enableDailySynchronizationHelp": "If the field is enabled products will be synchronized at the mentioned time each day",
"timeDailySynchronization": "Time for Daily Product Synchronization",
Expand All @@ -108,6 +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": "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",
Expand Down
8 changes: 5 additions & 3 deletions src/Subscriber/FrontendSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,7 +45,7 @@ public function onHeaderLoaded(HeaderPageletLoadedEvent $event): void

public function onKernelResponse(ResponseEvent $event): void
{
if (!($event->getResponse() instanceof StorefrontResponse)) {
if (!($event->getResponse())) {
return;
}

Expand All @@ -59,7 +58,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());
Expand Down

0 comments on commit cf7738a

Please sign in to comment.