diff --git a/Controller/Ajax/Analytics.php b/Controller/Ajax/Analytics.php index 06546e00..e2c6f5d2 100644 --- a/Controller/Ajax/Analytics.php +++ b/Controller/Ajax/Analytics.php @@ -39,7 +39,6 @@ public function execute() { $result = $this->resultJsonFactory->create(); if ($this->config->isAnalyticsEnabled()) { - $type = $this->getRequest()->getParam('type'); $profileKey = $this->config->getProfileKey(); @@ -63,6 +62,7 @@ public function execute() $result->setData(['success' => false, 'message' => $e->getMessage()]); } } + return $result; } } diff --git a/Model/Client/Request/AnalyticsRequest.php b/Model/Client/Request/AnalyticsRequest.php index a1dbc0c0..3423ea18 100644 --- a/Model/Client/Request/AnalyticsRequest.php +++ b/Model/Client/Request/AnalyticsRequest.php @@ -21,26 +21,41 @@ class AnalyticsRequest extends Request protected $apiUrl = 'https://navigator-analytics.tweakwise.com/api'; + /** + * @return string + */ public function isPostRequest() { return true; } + /** + * @return string + */ public function getApiurl() { return $this->apiUrl; } + /** + * @return string + */ public function setProfileKey(string $profileKey) { $this->setParameter('ProfileKey', $profileKey); } + /** + * @return string + */ public function setPath($path) { $this->path = $path; } + /** + * @return string + */ public function getProfileKey() { $profileKey = $this->getCookie($this->config->getPersonalMerchandisingCookieName()); @@ -48,6 +63,7 @@ public function getProfileKey() $profileKey = $this->generateProfileKey(); $this->setCookie('profileKey', $profileKey); } + return $profileKey; } } diff --git a/Model/PersonalMerchandisingConfig.php b/Model/PersonalMerchandisingConfig.php index 2bf447d6..2f862c59 100644 --- a/Model/PersonalMerchandisingConfig.php +++ b/Model/PersonalMerchandisingConfig.php @@ -23,8 +23,7 @@ public function __construct( private CookieManagerInterface $cookieManager, private CookieMetadataFactory $cookieMetadataFactory ) { - parent::__construct($config, $jsonSerializer, $request, $state, - $configWriter, $cacheTypeList); + parent::__construct($config, $jsonSerializer, $request, $state, $configWriter, $cacheTypeList); } /** @@ -36,6 +35,9 @@ public function isAnalyticsEnabled(Store $store = null) return (bool)$this->getStoreConfig('tweakwise/personal_merchandising/analytics_enabled', $store); } + /** + * @return string|null + */ public function getProfileKey() { $profileKey = $this->cookieManager->getCookie( @@ -43,7 +45,7 @@ public function getProfileKey() null ); - if($this->isAnalyticsEnabled()) { + if ($this->isAnalyticsEnabled()) { if ($profileKey === null) { $profileKey = $this->generateProfileKey(); $this->cookieManager->setPublicCookie( @@ -53,9 +55,13 @@ public function getProfileKey() ); } } + return $profileKey; } + /** + * @return string + */ private function getCookieMetadata() { return $this->cookieMetadataFactory @@ -65,6 +71,9 @@ private function getCookieMetadata() ->setSecure(true); } + /** + * @return string + */ private function generateProfileKey() { return uniqid('', true); diff --git a/Observer/TweakwiseCheckout.php b/Observer/TweakwiseCheckout.php index 29add3fd..7c1896d1 100644 --- a/Observer/TweakwiseCheckout.php +++ b/Observer/TweakwiseCheckout.php @@ -26,7 +26,6 @@ class TweakwiseCheckout implements ObserverInterface * @param Helper $helper * @param StoreManagerInterface $storeManager * @param PersonalMerchandisingConfig $config - * @param CookieManagerInterface $cookieManager */ public function __construct( private readonly RequestFactory $requestFactory, @@ -51,7 +50,6 @@ public function execute(Observer $observer) $items = $order->getAllItems(); $this->sendCheckout($items); - } } @@ -79,6 +77,7 @@ private function sendCheckout($items) try { $this->client->request($tweakwiseRequest); } catch (\Exception $e) { + // @phpcs:ignore // Do nothing } } diff --git a/view/frontend/templates/product/page.phtml b/view/frontend/templates/product/page.phtml index f72cea5d..087223dd 100644 --- a/view/frontend/templates/product/page.phtml +++ b/view/frontend/templates/product/page.phtml @@ -5,20 +5,14 @@ use Magento\Framework\Escaper; -$tweakwiseCookieName = $block->getCookieName(); -$apiUrl = $block->getApiUrl(); $productKey = $block->getProductKey(); -$instanceKey = $block->getInstanceKey(); ?>