From cc2e9a5fc6dd5bac9c644f93ea93aebf504b0ff1 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Mon, 24 Jun 2024 16:08:36 +0200 Subject: [PATCH 1/2] [Fixed] overwriting existing settings accidentally the existing settings were overwritten --- Setup/Actions.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Setup/Actions.php b/Setup/Actions.php index ff577d6..25a6e45 100644 --- a/Setup/Actions.php +++ b/Setup/Actions.php @@ -7,6 +7,7 @@ namespace D3\GoogleAnalytics4\Setup; use D3\GoogleAnalytics4\Application\Model\Constants; use OxidEsales\Eshop\Core\Registry; +use OxidEsales\Eshop\Core\ViewConfig; class Actions { @@ -19,12 +20,23 @@ class Actions public function d3SaveDefaultSettings(string $sVarType, string $sSettingName, string $sSettingValue){ $oConfig = Registry::getConfig(); - $oConfig->saveShopConfVar( - $sVarType, - Constants::OXID_MODULE_ID.$sSettingName, - $sSettingValue, - $oConfig->getShopId(), - Constants::OXID_MODULE_ID - ); + if (false === ($this->d3GetModuleConfigParam($sSettingName) === $sSettingValue)){ + $oConfig->saveShopConfVar( + $sVarType, + Constants::OXID_MODULE_ID.$sSettingName, + $sSettingValue, + $oConfig->getShopId(), + Constants::OXID_MODULE_ID + ); + } + } + + /** + * @param string $configParamName + * @return mixed + */ + public function d3GetModuleConfigParam(string $configParamName) + { + return Registry::get(ViewConfig::class)->d3GetModuleConfigParam($configParamName); } } \ No newline at end of file From 16387c59bb1bb1243ca4d82cf3d6a300840d2541 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Mon, 24 Jun 2024 16:08:36 +0200 Subject: [PATCH 2/2] [Fixed] overwriting existing settings accidentally the existing settings were overwritten --- Setup/Actions.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Setup/Actions.php b/Setup/Actions.php index ff577d6..8d37da3 100644 --- a/Setup/Actions.php +++ b/Setup/Actions.php @@ -7,6 +7,7 @@ namespace D3\GoogleAnalytics4\Setup; use D3\GoogleAnalytics4\Application\Model\Constants; use OxidEsales\Eshop\Core\Registry; +use OxidEsales\Eshop\Core\ViewConfig; class Actions { @@ -19,6 +20,10 @@ class Actions public function d3SaveDefaultSettings(string $sVarType, string $sSettingName, string $sSettingValue){ $oConfig = Registry::getConfig(); + if (trim($this->d3GetModuleConfigParam($sSettingName)) !== trim($sSettingValue)){ + $sSettingValue = trim($this->d3GetModuleConfigParam($sSettingName)); + } + $oConfig->saveShopConfVar( $sVarType, Constants::OXID_MODULE_ID.$sSettingName, @@ -27,4 +32,13 @@ class Actions Constants::OXID_MODULE_ID ); } + + /** + * @param string $configParamName + * @return mixed + */ + public function d3GetModuleConfigParam(string $configParamName) + { + return Registry::get(ViewConfig::class)->d3GetModuleConfigParam($configParamName); + } } \ No newline at end of file