From 7911fc90daa733fbe897465da36897231d8e15e4 Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Tue, 1 Aug 2023 20:17:09 +0200 Subject: [PATCH 1/3] fix migration fragment to inpage --- alma/upgrade/upgrade-3.0.0.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/alma/upgrade/upgrade-3.0.0.php b/alma/upgrade/upgrade-3.0.0.php index 69b5e8256..7e66e8e61 100644 --- a/alma/upgrade/upgrade-3.0.0.php +++ b/alma/upgrade/upgrade-3.0.0.php @@ -21,7 +21,11 @@ * @copyright 2018-2023 Alma SAS * @license https://opensource.org/licenses/MIT The MIT License */ + +use Alma\PrestaShop\Forms\InpageAdminFormBuilder; +use Alma\PrestaShop\Helpers\ApiHelper; use Alma\PrestaShop\Helpers\ConstantsHelper; +use Alma\PrestaShop\Helpers\SettingsHelper; if (!defined('_PS_VERSION_')) { exit; @@ -32,10 +36,14 @@ function upgrade_module_3_0_0($module) $module->registerHooks(); try { - \Alma\PrestaShop\Helpers\ApiHelper::getMerchant($module); + ApiHelper::getMerchant($module); } catch (\Exception $e) { } + if (Configuration::get('ALMA_ACTIVATE_FRAGMENT') == 1) { + SettingsHelper::updateValue(InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE, 1); + } + if (version_compare(_PS_VERSION_, '1.5.5.0', '<')) { Tools::clearCache(); From cf46b1be64fffc531775421094c3575401e95e1b Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Wed, 2 Aug 2023 10:13:45 +0200 Subject: [PATCH 2/3] update key config inpage --- alma/upgrade/upgrade-3.0.0.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/alma/upgrade/upgrade-3.0.0.php b/alma/upgrade/upgrade-3.0.0.php index 7e66e8e61..8b8c8adde 100644 --- a/alma/upgrade/upgrade-3.0.0.php +++ b/alma/upgrade/upgrade-3.0.0.php @@ -40,9 +40,11 @@ function upgrade_module_3_0_0($module) } catch (\Exception $e) { } - if (Configuration::get('ALMA_ACTIVATE_FRAGMENT') == 1) { - SettingsHelper::updateValue(InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE, 1); - } + // Migration value option of In-Page v1 to In-Page v2 + SettingsHelper::updateValue( + InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE, + Configuration::get('ALMA_ACTIVATE_FRAGMENT') + ); if (version_compare(_PS_VERSION_, '1.5.5.0', '<')) { Tools::clearCache(); From 2d6b0451e9df369fba67cd3be1b3f23e1f0112a5 Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Wed, 2 Aug 2023 11:52:23 +0200 Subject: [PATCH 3/3] fix migration inpage --- alma/lib/Helpers/ApiHelper.php | 6 +++--- alma/upgrade/upgrade-3.0.0.php | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/alma/lib/Helpers/ApiHelper.php b/alma/lib/Helpers/ApiHelper.php index 62792b0c2..36f6ccb02 100644 --- a/alma/lib/Helpers/ApiHelper.php +++ b/alma/lib/Helpers/ApiHelper.php @@ -82,14 +82,14 @@ protected static function saveFeatureFlag($merchant, $merchantKey, $configKey) $value = 1; if (property_exists($merchant, $merchantKey)) { - $value = (int) $merchant->$merchantKey; + $value = $merchant->$merchantKey; } - SettingsHelper::updateValue($configKey, $value); + SettingsHelper::updateValue($configKey, (int) $value); // If Inpage not allowed we ensure that inpage is deactivated in database if (0 === $value) { - SettingsHelper::updateValue(InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE, $value); + SettingsHelper::updateValue(InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE, (int) $value); } } } diff --git a/alma/upgrade/upgrade-3.0.0.php b/alma/upgrade/upgrade-3.0.0.php index 8b8c8adde..86124c185 100644 --- a/alma/upgrade/upgrade-3.0.0.php +++ b/alma/upgrade/upgrade-3.0.0.php @@ -21,7 +21,6 @@ * @copyright 2018-2023 Alma SAS * @license https://opensource.org/licenses/MIT The MIT License */ - use Alma\PrestaShop\Forms\InpageAdminFormBuilder; use Alma\PrestaShop\Helpers\ApiHelper; use Alma\PrestaShop\Helpers\ConstantsHelper;