diff --git a/Block/Catalog/Product/ViewedProduct.php b/Block/Catalog/Product/ViewedProduct.php index 86082cd..2b70a91 100644 --- a/Block/Catalog/Product/ViewedProduct.php +++ b/Block/Catalog/Product/ViewedProduct.php @@ -200,7 +200,8 @@ public function getViewedProductJson() 'URL' => $_product->getProductUrl(), 'Price' => $this->getPrice(), 'FinalPrice' => $this->getFinalPrice(), - 'Categories' => $this->getProductCategories() + 'Categories' => $this->getProductCategories(), + 'StoreId' => $this->_klaviyoScopeSetting->storeId ]; if ($this->getProductImage()) { @@ -224,7 +225,8 @@ public function getViewedItemJson() 'Categories' => $this->getProductCategories(), 'Metadata' => array( 'Price' => $this->getPrice() - ) + ), + 'StoreId' => $this->_klaviyoScopeSetting->storeId ]; if ($this->getProductImage()) { diff --git a/CHANGELOG.md b/CHANGELOG.md index e1e4502..9a9b952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### [Unreleased] +### [4.2.0] - 2024-09-17 + +#### Added +- Adds StoreId field to Viewed Product events + +#### Changed +- Updated the klaviyo onsite javascript to the new url format + +#### Fixed +- Removes call to isLoggerEnabled() in Logger __construct to address "Area Code is already set" issue when running consumer-based jobs + ### [4.1.4] - 2024-05-22 #### Changed @@ -287,7 +298,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 -[Unreleased]: https://github.com/klaviyo/magento2-klaviyo/compare/4.1.4...HEAD +[Unreleased]: https://github.com/klaviyo/magento2-klaviyo/compare/4.2.0...HEAD +[4.2.0]: https://github.com/klaviyo/magento2-klaviyo/compare/4.1.4...4.2.0 [4.1.4]: https://github.com/klaviyo/magento2-klaviyo/compare/4.1.3...4.1.4 [4.1.3]: https://github.com/klaviyo/magento2-klaviyo/compare/4.1.2...4.1.3 [4.1.2]: https://github.com/klaviyo/magento2-klaviyo/compare/4.1.1...4.1.2 diff --git a/Helper/Logger.php b/Helper/Logger.php index 9130a45..22a6a39 100644 --- a/Helper/Logger.php +++ b/Helper/Logger.php @@ -28,10 +28,10 @@ class Logger protected $_klaviyoLogger; /** - * is the logger enabled? - * @var boolean + * Klaviyo Scope setting Helper + * @var ScopeSetting */ - protected $_loggerEnabled; + protected $_scopeSetting; public function __construct( DirectoryList $dir, @@ -41,7 +41,7 @@ public function __construct( ) { $this->_dir = $dir; $this->_klaviyoLogger = $klaviyoLogger; - $this->_loggerEnabled = $klaviyoScopeSetting->isLoggerEnabled(); + $this->_scopeSetting = $klaviyoScopeSetting; $this->_logPath = (!empty($logPath)) ? $logPath : $this->_dir->getPath('log') . '/klaviyo.log'; } @@ -60,7 +60,7 @@ public function getPath() */ public function log($message) { - if ($this->_loggerEnabled) { + if ($this->_scopeSetting->isLoggerEnabled()) { $this->_klaviyoLogger->info($message); } } diff --git a/Helper/ScopeSetting.php b/Helper/ScopeSetting.php index 20f24be..37def20 100755 --- a/Helper/ScopeSetting.php +++ b/Helper/ScopeSetting.php @@ -52,7 +52,7 @@ class ScopeSetting extends \Magento\Framework\App\Helper\AbstractHelper /** * @var int */ - protected $_storeId; + public $storeId; /** * @var \Magento\Framework\Module\ModuleListInterface @@ -75,7 +75,7 @@ public function __construct( $this->_scopeConfig = $context->getScopeConfig(); $this->_request = $context->getRequest(); $this->_state = $state; - $this->_storeId = $storeManager->getStore()->getId(); + $this->storeId = $storeManager->getStore()->getId(); $this->_moduleList = $moduleList; $this->_configWriter = $configWriter; } @@ -114,7 +114,7 @@ protected function getScopeSetting($path, $storeId = null) $scopedWebsiteCode = $this->_request->getParam('website'); } else { // In frontend area. Only concerned with store for frontend. - $scopedStoreCode = $this->_storeId; + $scopedStoreCode = $this->storeId; } if (isset($scopedStoreCode)) { @@ -142,7 +142,7 @@ protected function setScopeSetting($path, $value) $scopedWebsiteCode = $this->_request->getParam('website'); } else { // In frontend area. Only concerned with store for frontend. - $scopedStoreCode = $this->_storeId; + $scopedStoreCode = $this->storeId; } if (isset($scopedStoreCode)) { diff --git a/composer.dev.json b/composer.dev.json index 8fe7885..6402c9c 100644 --- a/composer.dev.json +++ b/composer.dev.json @@ -2,7 +2,7 @@ "name": "klaviyo/magento2-extension-dev", "description": "The local development composer file. This is used for local and continuous integration setup/testing.", "type": "magento2-module", - "version": "4.1.4", + "version": "4.2.0", "autoload": { "psr-4": { "Klaviyo\\Reclaim\\": "" diff --git a/composer.json b/composer.json index eb0f645..0473cd1 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "klaviyo/magento2-extension", "description": "Klaviyo extension for Magento 2. Allows pushing newsletters to Klaviyo's platform and more.", "type": "magento2-module", - "version": "4.1.4", + "version": "4.2.0", "autoload": { "files": [ "registration.php" diff --git a/etc/module.xml b/etc/module.xml index 2f9cc40..6ada556 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/view/frontend/templates/analytics/initialize.phtml b/view/frontend/templates/analytics/initialize.phtml index 797b8f3..326d8b0 100644 --- a/view/frontend/templates/analytics/initialize.phtml +++ b/view/frontend/templates/analytics/initialize.phtml @@ -1,7 +1,8 @@ getPublicApiKey(); ?> isKlaviyoEnabled() && $klaviyoKey ): ?> - + escapeHtml($klaviyoKey); $klaviyoSrc = 'https://static.klaviyo.com/onsite/js/'. $escapedKey . '/klaviyo.js'?> +