Skip to content

Commit 45edaf7

Browse files
authored
Merge pull request #64 from webmatch/feature/WBMSWPLUG-98
increase performance in admin, fix cross selling by harden js-condition
2 parents 5dda529 + a326be3 commit 45edaf7

File tree

6 files changed

+30
-17
lines changed

6 files changed

+30
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.1.4
2+
* increase performance in admin
3+
* fix cross selling clicks by harden js-condition
4+
15
# 2.1.3
26
* add new store-api routes to import and export
37

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "webmatch/tag-manager-sw6",
33
"keywords": ["shopware6", "shopware-6", "GTM", "datalayer", "datalayer-configuration", "google-tag-manager", "shopware-plugin"],
44
"description": "Google Tag Manager + Enhanced E-Commerce Tracking",
5-
"version": "2.1.3",
5+
"version": "2.1.4",
66
"type": "shopware-platform-plugin",
77
"license": "proprietary",
88
"require": {

src/Resources/app/storefront/dist/storefront/js/wbm-tag-manager-ecomm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/app/storefront/src/plugin/productClickTracking.plugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ export default class ProductClickTracking extends Plugin {
9898
}
9999
// enabled quickview feature of SwagCmsExtension?
100100
const quickviewSelector = '[data-swag-cms-extensions-quickview="true"]';
101-
if (this.el.closest('.cms-section').querySelector(quickviewSelector) !== null
101+
if ((this.el.closest('.cms-section') !== null
102+
&& this.el.closest('.cms-section').querySelector(quickviewSelector) !== null)
102103
|| (document.body.classList.contains('is-ctl-search')
104+
&& this.el.closest('.container-main') !== null
103105
&& this.el.closest('.container-main').querySelector(quickviewSelector) !== null)
104106
) {
105107
redirect = false;

src/Services/DataLayerModulesInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ interface DataLayerModulesInterface
66
{
77
public function getModules(): array;
88

9-
public function getContainerId(): ?string;
9+
public function getContainerId(?string $salesChannelId = null): ?string;
1010

11-
public function isActive(): ?bool;
11+
public function isActive(?string $salesChannelId = null): ?bool;
1212

13-
public function isTrackingProductClicks(): ?bool;
13+
public function isTrackingProductClicks(?string $salesChannelId = null): ?bool;
1414

15-
public function hasSWConsentSupport(): int;
15+
public function hasSWConsentSupport(?string $salesChannelId = null): int;
1616

17-
public function getScriptTagAttributes(): string;
17+
public function getScriptTagAttributes(?string $salesChannelId = null): string;
1818

19-
public function getExtendedURLParameter(): string;
19+
public function getExtendedURLParameter(?string $salesChannelId = null): string;
2020
}

src/Subscriber/KernelEventsSubscriber.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,24 @@ public static function getSubscribedEvents(): array
5151

5252
public function getDataLayerForXmlHttpRequest(ControllerEvent $event): void
5353
{
54+
$modules = $this->modules->getModules();
55+
$route = $event->getRequest()->attributes->get('_route');
56+
57+
if (!array_key_exists($route, $modules)
58+
|| empty($modules[$route])
59+
|| $this->session->has(SessionUtility::ATTRIBUTE_NAME)
60+
) {
61+
return;
62+
}
63+
5464
$salesChannelId = $event->getRequest()->get('sw-sales-channel-id');
5565
$isActive = !empty($this->modules->getContainerId($salesChannelId)) && $this->modules->isActive($salesChannelId);
5666

57-
if ($isActive && !$this->session->get(SessionUtility::ATTRIBUTE_NAME)) {
58-
$modules = $this->modules->getModules();
59-
$route = $event->getRequest()->attributes->get('_route');
60-
61-
if (array_key_exists($route, $modules) && !empty($modules[$route])) {
62-
$this->dataLayerRenderer->setVariables($route, [])->renderDataLayer($route);
63-
}
67+
if (!$isActive) {
68+
return;
6469
}
70+
71+
$this->dataLayerRenderer->setVariables($route, [])->renderDataLayer($route);
6572
}
6673

6774
public function prependDataLayerToResponse(ResponseEvent $event): void
@@ -71,7 +78,7 @@ public function prependDataLayerToResponse(ResponseEvent $event): void
7178
$storedDatalayer = $this->session->get(SessionUtility::ATTRIBUTE_NAME);
7279
$this->session->remove(SessionUtility::ATTRIBUTE_NAME);
7380

74-
$route = $event->getRequest()->attributes->get('_route');
81+
$route = $request->attributes->get('_route');
7582
$dataLayer = $this->dataLayerRenderer->getDataLayer($route);
7683
if ($dataLayer !== null) {
7784
$dataLayer = $this->session->injectSessionVars($dataLayer);

0 commit comments

Comments
 (0)