In PrestaShop (specifically v1.7.5) one can get an instance of the module class by calling
$module = Module::getInstanceByName(\'theModuleName\');
If you are working in a child from ProductListingFrontController, this->module is not defined. If you call the module with getInstanceByName, you get an instance in order to work with it later. The string way doesn´t work in Listing controllers.
class mymoduleMyControllerModuleFrontController extends ProductListingFrontControllerCore
{
public function init()
{
parent::init();
$this -> module = Module::getInstanceByName('mymodule');
}
}
You can access the module name (along with the rest from the module class) by:
$theModuleName = $this->module->name;
Using Prestashop core module "Cronjobs" as an example, you can also run module methods inside a front controller like this:
class CronjobsCallbackModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
$this->module->sendCallback();
die;
}
}