Affects Version/s: 22.214.171.124
Fix Version/s: None
Component/s: 2.5_Shop configuring - MultiStore
Security Level: All-users
It seems that module installation doesn't work as expected in multishop environment.
1) install PrestaShop
2) create 2 shops: "shop A" and "shop B"
3) create 2 employees: "Employee A" (this employee can only access to "shop A") and "Employee B" (can only access to "shop B")
4) login in backoffice as "Employee A". Install a module. It works correctly in "shop A"
5) login in backoffice as "Employee B". The module is installed but not active
6) Activate the module
7) The issue is that the module is active, but it's not working properly because no hook is configured for that module in "shop B".
The problem seems in the registerHook function.
It calls Shop::getShops() to retrieve all shops so it can register hooks to all shops.
But Shop::getShops() retrieve only shops that the employee can manage (in this case only "shop A", not "shop B"), so the install process can't hook to "shop B".
In module install() method, if you call registerHook with an explicit list of shops that contains both "shop A" and "shop B", all works as expected: the module is installed in "shop B" but not active (no hook are called for "shop A" customers). Activating it results in a fully working module.
Suggestions: Shop::getShops() should retrieve all shops OR registerHook() need another method to retrieve the "true" shop list.