jsmit2 Posted January 19, 2015 Share Posted January 19, 2015 Does anyone know if it is possible to install a module that is on the server but not installed, trough another modules code?. I want to install a modules wich my module depends on. Any help would be appreciated. Link to comment Share on other sites More sharing options...
Krystian Podemski Posted January 19, 2015 Share Posted January 19, 2015 (edited) You can check if required module is installed by simply adding this: $this->dependencies = array('some_module_name'); to your module __construct method. User will not be able to install module before installing required module. This is how you can install module with code: $module = Module::getInstanceByName('module_name'); $module->install(); Edited January 19, 2015 by Krystian Podemski (see edit history) 2 Link to comment Share on other sites More sharing options...
jsmit2 Posted January 19, 2015 Author Share Posted January 19, 2015 You can check if required module is installed by simply adding this: $this->dependencies = array('some_module_name'); to your module __construct method. User will not be able to install module before installing required module. This is how you can install module with code: $module = Module::getInstanceByName('module_name'); $module->install(); Thanks for your answer With this suggestion I can send a message requiring them to install it. That can work but is it possible to install it for them? because that would be easier on the user. Link to comment Share on other sites More sharing options...
Krystian Podemski Posted January 19, 2015 Share Posted January 19, 2015 Yes, you can, just do not run code dependent on other module if module is not yet installed, check in __construct/getContent or other method if module is installed and if not install module using this little snippet from my previous post. Link to comment Share on other sites More sharing options...
jsmit2 Posted January 19, 2015 Author Share Posted January 19, 2015 Yes, you can, just do not run code dependent on other module if module is not yet installed, check in __construct/getContent or other method if module is installed and if not install module using this little snippet from my previous post. Thanks for your help! I am running code dependant on the prestashops cronjob module. And since not everyone has SSH access and/or a cronjob webservice availible this looked like the best solution Link to comment Share on other sites More sharing options...
cristic Posted January 19, 2015 Share Posted January 19, 2015 You also have to check if the module folder actually exists on the server. Link to comment Share on other sites More sharing options...
Krystian Podemski Posted January 19, 2015 Share Posted January 19, 2015 You also have to check if the module folder actually exists on the server. No, there is no need to check this. There is need to check if (in this case) $module is Validate::isLoadedObject, checking for folder doesn't help at all because it's already done in getInstanceByName method. Link to comment Share on other sites More sharing options...
cristic Posted January 19, 2015 Share Posted January 19, 2015 No, there is no need to check this. There is need to check if (in this case) $module is Validate::isLoadedObject, checking for folder doesn't help at all because it's already done in getInstanceByName method. Yes, you are right. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now