Jump to content

Installing modules via code


jsmit2

Recommended Posts

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 by Krystian Podemski (see edit history)
  • Like 2
Link to comment
Share on other sites

 

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...