From c12ce0837378f0ee8b39bcd2c261cb1ab1a48211 Mon Sep 17 00:00:00 2001 From: matthieu-rolland Date: Wed, 5 Oct 2022 17:47:03 +0200 Subject: [PATCH] make query multistore compatible --- classes/module/Module.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/classes/module/Module.php b/classes/module/Module.php index 1ce868589bdbd..be3c949a981f2 100755 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -1698,9 +1698,14 @@ public static function getModulesInstalled($position = 0) */ public static function getModulesInstalledAndEnabled() { - $sql = 'SELECT m.* FROM `' . _DB_PREFIX_ . 'module` m WHERE `active` = 1'; + $id_shops = Shop::getContextListShopID(); - return Db::getInstance()->executeS($sql); + $select = 'SELECT m.`id_module`, m.`name`, m.`version`'; + $from = ' FROM `' . _DB_PREFIX_ . 'module` m'; + $from .= ' INNER JOIN `' . _DB_PREFIX_ . 'module_shop` ms ON ms.`id_module` = m.`id_module`'; + $from .= ' AND ms.`id_shop` IN (' . (implode(',', array_map('intval', $id_shops))) . ')'; + + return Db::getInstance()->executeS($select . $from); } /**