Skip to content

Commit

Permalink
Merge pull request #195 from alma/feat/MPP-506/activate-in-page-v2-au…
Browse files Browse the repository at this point in the history
…tomatically-if-in-page-v1-was-activated

Feat/mpp 506/activate in page v2 automatically if in page v1 was activated
  • Loading branch information
Benjamin-Freoua-Alma authored Aug 2, 2023
2 parents 3c47137 + 2d6b045 commit 39f338c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions alma/lib/Helpers/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
11 changes: 10 additions & 1 deletion alma/upgrade/upgrade-3.0.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
* @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;
Expand All @@ -32,10 +35,16 @@ function upgrade_module_3_0_0($module)
$module->registerHooks();

try {
\Alma\PrestaShop\Helpers\ApiHelper::getMerchant($module);
ApiHelper::getMerchant($module);
} catch (\Exception $e) {
}

// 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();

Expand Down

0 comments on commit 39f338c

Please sign in to comment.