From 81db8a1be5e7280c7486bf97b6064f779c8cd297 Mon Sep 17 00:00:00 2001 From: Claire Kolln <78871498+cykolln@users.noreply.github.com> Date: Tue, 24 Sep 2024 08:59:14 -0400 Subject: [PATCH] Revert "Adds StoreID field to Added to Cart and Viewed Product events (#303)" (#311) This reverts commit 5344d1258f9edf07a6c829c1a91cc51a11488b2c. --- Block/Catalog/Product/ViewedProduct.php | 6 ++---- CHANGELOG.md | 6 ------ Cron/KlSyncs.php | 4 ++-- Helper/ScopeSetting.php | 8 ++++---- Observer/SalesQuoteSaveAfter.php | 2 +- 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Block/Catalog/Product/ViewedProduct.php b/Block/Catalog/Product/ViewedProduct.php index 79cf52e..86082cd 100644 --- a/Block/Catalog/Product/ViewedProduct.php +++ b/Block/Catalog/Product/ViewedProduct.php @@ -200,8 +200,7 @@ public function getViewedProductJson() 'URL' => $_product->getProductUrl(), 'Price' => $this->getPrice(), 'FinalPrice' => $this->getFinalPrice(), - 'Categories' => $this->getProductCategories(), - 'StoreID' => $this->_klaviyoScopeSetting->storeId + 'Categories' => $this->getProductCategories() ]; if ($this->getProductImage()) { @@ -225,8 +224,7 @@ 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 994ec36..e1e4502 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### [Unreleased] -#### Added -- Adds StoreID field to Viewed Product events - -#### Changed -- Updates StoreId field to StoreID for Added to Cart events - ### [4.1.4] - 2024-05-22 #### Changed diff --git a/Cron/KlSyncs.php b/Cron/KlSyncs.php index 6db306a..069348d 100644 --- a/Cron/KlSyncs.php +++ b/Cron/KlSyncs.php @@ -144,8 +144,8 @@ private function sendUpdatesToApp(array $groupedRows, bool $isRetry = false) //TODO: if conditional for backward compatibility, needs to be removed in future versions $storeId = ''; - if (isset($decodedPayload['StoreID'])) { - $storeId = $decodedPayload['StoreID']; + if (isset($decodedPayload['StoreId'])) { + $storeId = $decodedPayload['StoreId']; } $response = $this->_dataHelper->klaviyoTrackEvent( diff --git a/Helper/ScopeSetting.php b/Helper/ScopeSetting.php index 37def20..20f24be 100755 --- a/Helper/ScopeSetting.php +++ b/Helper/ScopeSetting.php @@ -52,7 +52,7 @@ class ScopeSetting extends \Magento\Framework\App\Helper\AbstractHelper /** * @var int */ - public $storeId; + protected $_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/Observer/SalesQuoteSaveAfter.php b/Observer/SalesQuoteSaveAfter.php index dd6e3ab..192212c 100644 --- a/Observer/SalesQuoteSaveAfter.php +++ b/Observer/SalesQuoteSaveAfter.php @@ -98,7 +98,7 @@ public function execute(Observer $observer) // Setting QuoteId at this point since the MaskedQuoteId is not updated when this event is dispatched, $klAddedToCartPayload['QuoteId'] = isset($encodedCustomerId) ? "kx_identifier_$encodedCustomerId" : $quote->getId(); // Setting StoreId in payload - $klAddedToCartPayload['StoreID'] = $quote->getStoreId(); + $klAddedToCartPayload['StoreId'] = $quote->getStoreId(); $stringifiedPayload = json_encode($klAddedToCartPayload);