diff --git a/Helper/Config.php b/Helper/Config.php index 2d03a84..d322cc9 100644 --- a/Helper/Config.php +++ b/Helper/Config.php @@ -197,6 +197,29 @@ public function isPayment($module = '') return $isPayment; } + /** + * @param string $scopeType + * @param string|int $scopeId + * @param string $module + * @return bool + */ + public function isScopeActive($scopeType, $scopeId, $module = 'core') + { + if ($scopeType === ScopeInterface::SCOPE_STORES) { + return $this->isActive($scopeId, $module); + } + + if ($this->isPayment($module)) { + $configPath = $this->getPaymentConfigPath('active', $module); + } + + if (!isset($configPath)) { + $configPath = $this->getConfigPath('active', $module); + } + + return $this->scopeConfig->isSetFlag($configPath, $scopeType, $scopeId); + } + /** * @param Store|int|string|null $store * @param string $module @@ -207,6 +230,8 @@ public function isPayment($module = '') */ public function isActive($store = null, $module = 'core') { + $store = $store ?? $this->storeManager->getStore()->getId(); + if ($this->isPayment($module)) { $configPath = $this->getPaymentConfigPath('active', $module); } diff --git a/Observer/ConfigChangeObserver.php b/Observer/ConfigChangeObserver.php index 0e2d7a4..664a87a 100644 --- a/Observer/ConfigChangeObserver.php +++ b/Observer/ConfigChangeObserver.php @@ -144,7 +144,7 @@ public function execute(Observer $observer) $moduleConfigHelper = $this->configFactory->create($moduleName); - $isValid = $moduleConfigHelper->isActive($store); + $isValid = $moduleConfigHelper->isScopeActive($scope, $scopeId); if ($isActivated && !$isValid) { $moduleConfigHelper->deactivateModule($scope, $scopeId);