From 3d6edb8b97461a4d96179f8cb0f262acfc25b971 Mon Sep 17 00:00:00 2001 From: Kocmonavtik <61938582+Kocmonavtik@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:08:09 +0300 Subject: [PATCH] ref #91900 Fix module activation/deactivation (#220) --- CHANGELOG.md | 3 +++ VERSION | 2 +- retailcrm/lib/settings/RetailcrmSettings.php | 10 +++++++--- retailcrm/retailcrm.php | 7 ++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba02fe1..b078cf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v3.6.3 +* Исправление активации/деактивации модуля + ## v3.6.2 * Добавлена валидация валют при настройке модуля diff --git a/VERSION b/VERSION index b727628..4a788a0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.6.2 +3.6.3 diff --git a/retailcrm/lib/settings/RetailcrmSettings.php b/retailcrm/lib/settings/RetailcrmSettings.php index 7bdaf4d..1740ff2 100644 --- a/retailcrm/lib/settings/RetailcrmSettings.php +++ b/retailcrm/lib/settings/RetailcrmSettings.php @@ -71,9 +71,12 @@ class RetailcrmSettings if ($this->validator->validate(true)) { $this->settings->updateValueAll(); - if (array_key_exists('apiKey', $this->settings->getChanged())) { + $shopId = Context::getContext()->shop->id; + + if (array_key_exists('apiKey', $this->settings->getChanged()) + && !Configuration::get(RetailCRM::CLIENT_ID, null, null, $shopId)) { $this->setClientId(); - RetailCRM::updateCrmModuleState(Context::getContext()->shop->id); + RetailCRM::updateCrmModuleState($shopId); } } @@ -95,10 +98,11 @@ class RetailcrmSettings private function setClientId() { $context = Context::getContext(); + $clientId = uniqid(); Configuration::updateValue(RetailCRM::CLIENT_ID, hash( 'sha256', - $context->shop->id . Configuration::get('PS_SHOP_DOMAIN') + $context->shop->id . Configuration::get('PS_SHOP_DOMAIN') . $clientId )); return true; diff --git a/retailcrm/retailcrm.php b/retailcrm/retailcrm.php index 063c22a..e53a1f2 100755 --- a/retailcrm/retailcrm.php +++ b/retailcrm/retailcrm.php @@ -48,7 +48,7 @@ require_once dirname(__FILE__) . '/bootstrap.php'; class RetailCRM extends Module { - const VERSION = '3.6.2'; + const VERSION = '3.6.3'; const API_URL = 'RETAILCRM_ADDRESS'; const API_KEY = 'RETAILCRM_API_TOKEN'; @@ -309,7 +309,8 @@ class RetailCRM extends Module if (Shop::isFeatureActive()) { $shops = Shop::getShops(); } else { - $shops[] = Shop::getContext(); + $context = Context::getContext(); + $shops[]['id_shop'] = $context->shop->id; } foreach ($shops as $shop) { @@ -371,7 +372,7 @@ class RetailCRM extends Module return false; } - $context = Shop::getContext(); + $context = Context::getContext(); self::updateCrmModuleState($context->shop->id, false);