From e421dba4e9bc49243648420b179280aa46453a14 Mon Sep 17 00:00:00 2001 From: ah-net <103565001+ah-net@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:27:03 +0100 Subject: [PATCH 1/3] fix: analytics checkout --- Observer/TweakwiseCheckout.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Observer/TweakwiseCheckout.php b/Observer/TweakwiseCheckout.php index 2be13a8e..c1fdd3b7 100644 --- a/Observer/TweakwiseCheckout.php +++ b/Observer/TweakwiseCheckout.php @@ -43,9 +43,9 @@ public function __construct( * @return void * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function execute(Observer $observer) + public function execute(Observer $observer) : void { - if ($this->config->isAnalyticsEnabled('tweakwise/personal_merchandising/analytics_enabled')) { + if ($this->config->isAnalyticsEnabled()) { $order = $observer->getEvent()->getOrder(); // Get the order items $items = $order->getAllItems(); @@ -60,7 +60,7 @@ public function execute(Observer $observer) * @return void * @throws \Magento\Framework\Exception\NoSuchEntityException */ - private function sendCheckout($items) + private function sendCheckout($items) : void { $storeId = (int)$this->storeManager->getStore()->getId(); $profileKey = $this->config->getProfileKey(); From 6ce4750c66d3713c2f4a97d4e52db2c8acbd7288 Mon Sep 17 00:00:00 2001 From: ah-net <103565001+ah-net@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:28:57 +0100 Subject: [PATCH 2/3] Style fixes --- Observer/TweakwiseCheckout.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Observer/TweakwiseCheckout.php b/Observer/TweakwiseCheckout.php index c1fdd3b7..82b4863c 100644 --- a/Observer/TweakwiseCheckout.php +++ b/Observer/TweakwiseCheckout.php @@ -43,7 +43,7 @@ public function __construct( * @return void * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function execute(Observer $observer) : void + public function execute(Observer $observer): void { if ($this->config->isAnalyticsEnabled()) { $order = $observer->getEvent()->getOrder(); @@ -60,7 +60,7 @@ public function execute(Observer $observer) : void * @return void * @throws \Magento\Framework\Exception\NoSuchEntityException */ - private function sendCheckout($items) : void + private function sendCheckout($items): void { $storeId = (int)$this->storeManager->getStore()->getId(); $profileKey = $this->config->getProfileKey(); From 3d0f2d404deda432e3b0c334b623c363af02f6e9 Mon Sep 17 00:00:00 2001 From: ah-net <103565001+ah-net@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:57:50 +0100 Subject: [PATCH 3/3] Style fixes --- Controller/Ajax/Analytics.php | 2 +- Model/Client/Request.php | 4 ++-- Model/Client/Request/AnalyticsRequest.php | 10 +++++----- Model/Client/Request/PurchaseRequest.php | 6 +++--- Model/PersonalMerchandisingConfig.php | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Controller/Ajax/Analytics.php b/Controller/Ajax/Analytics.php index ea699614..344380fb 100644 --- a/Controller/Ajax/Analytics.php +++ b/Controller/Ajax/Analytics.php @@ -38,7 +38,7 @@ public function __construct( /** * @return ResponseInterface|Json|ResultInterface */ - public function execute() + public function execute(): ResponseInterface|Json|ResultInterface { $result = $this->resultJsonFactory->create(); if ($this->config->isAnalyticsEnabled()) { diff --git a/Model/Client/Request.php b/Model/Client/Request.php index 901f06fa..91c3c940 100644 --- a/Model/Client/Request.php +++ b/Model/Client/Request.php @@ -330,7 +330,7 @@ public function setProfileKey(string $profileKey) /** * @return string|null */ - public function setParameterArray(string $parameter, array $value) + public function setParameterArray(string $parameter, array $value): Request { $this->parameters[$parameter] = $value; return $this; @@ -339,7 +339,7 @@ public function setParameterArray(string $parameter, array $value) /** * @return string|null */ - public function isPostRequest() + public function isPostRequest(): bool { return false; } diff --git a/Model/Client/Request/AnalyticsRequest.php b/Model/Client/Request/AnalyticsRequest.php index 10abb1b7..71716eb3 100644 --- a/Model/Client/Request/AnalyticsRequest.php +++ b/Model/Client/Request/AnalyticsRequest.php @@ -24,7 +24,7 @@ class AnalyticsRequest extends Request /** * @return string */ - public function isPostRequest() + public function isPostRequest(): bool { return true; } @@ -32,7 +32,7 @@ public function isPostRequest() /** * @return string */ - public function getApiurl() + public function getApiurl(): string { return $this->apiUrl; } @@ -40,7 +40,7 @@ public function getApiurl() /** * @return void */ - public function setProfileKey(string $profileKey) + public function setProfileKey(string $profileKey): void { $this->setParameter('ProfileKey', $profileKey); } @@ -48,7 +48,7 @@ public function setProfileKey(string $profileKey) /** * @return void */ - public function setPath($path) + public function setPath($path): void { $this->path = $path; } @@ -56,7 +56,7 @@ public function setPath($path) /** * @return string */ - public function getProfileKey() + public function getProfileKey(): string { $profileKey = $this->getCookie($this->config->getPersonalMerchandisingCookieName()); if (!$profileKey) { diff --git a/Model/Client/Request/PurchaseRequest.php b/Model/Client/Request/PurchaseRequest.php index 094ee3aa..1bf62160 100644 --- a/Model/Client/Request/PurchaseRequest.php +++ b/Model/Client/Request/PurchaseRequest.php @@ -29,7 +29,7 @@ class PurchaseRequest extends Request /** * @return true */ - public function isPostRequest() + public function isPostRequest(): bool { return true; } @@ -37,7 +37,7 @@ public function isPostRequest() /** * @return mixed|string */ - public function getApiurl() + public function getApiurl(): string { return $this->apiUrl; } @@ -47,7 +47,7 @@ public function getApiurl() * * @return void */ - public function setProfileKey(string $profileKey) + public function setProfileKey(string $profileKey): void { $this->setParameter('ProfileKey', $profileKey); } diff --git a/Model/PersonalMerchandisingConfig.php b/Model/PersonalMerchandisingConfig.php index 066859cf..6eedfe17 100644 --- a/Model/PersonalMerchandisingConfig.php +++ b/Model/PersonalMerchandisingConfig.php @@ -31,7 +31,7 @@ public function __construct( * @param Store|null $store * @return bool */ - public function isAnalyticsEnabled(Store $store = null) + public function isAnalyticsEnabled(Store $store = null): bool { return (bool)$this->getStoreConfig('tweakwise/personal_merchandising/analytics_enabled', $store); } @@ -39,7 +39,7 @@ public function isAnalyticsEnabled(Store $store = null) /** * @return string|null */ - public function getProfileKey() + public function getProfileKey(): ?string { $profileKey = $this->cookieManager->getCookie( $this->getPersonalMerchandisingCookieName(), @@ -61,9 +61,9 @@ public function getProfileKey() } /** - * @return string + * @return CookieMetadataInterface */ - private function getCookieMetadata() + private function getCookieMetadata(): CookieMetadataInterface { return $this->cookieMetadataFactory ->createPublicCookieMetadata() @@ -75,7 +75,7 @@ private function getCookieMetadata() /** * @return string */ - private function generateProfileKey() + private function generateProfileKey(): string { return uniqid('', true); }