diff --git a/src/DependencyBuilder.php b/src/DependencyBuilder.php index 341fc8f..8e80488 100644 --- a/src/DependencyBuilder.php +++ b/src/DependencyBuilder.php @@ -310,6 +310,25 @@ private function getDependencies($addRoutes = false) ) ); + if ($dependencyData && is_array($dependencyData) && !empty($dependencyData['id_module'])) { + // For PS < 8.0, enable/disable for a module is decided by the shop association + // We assume that if the module is disabled for one shop, i's considered as disabled + $isModuleActiveForAllShops = (bool) \DbCore::getInstance()->getValue( + sprintf("SELECT id_module + FROM `%smodule_shop` + WHERE id_module=%d AND id_shop IN ('%s') + GROUP BY id_module + HAVING COUNT(*)=%d", + _DB_PREFIX_, + (int) $dependencyData['id_module'], + implode(',', array_map('intval', \Shop::getContextListShopID())), + (int) count(\Shop::getContextListShopID()) + ) + ); + + $dependencyData['active'] = $isModuleActiveForAllShops; + } + if ($addRoutes) { $dependencies[$dependency['name']] = array_merge( $dependency,