问题
In PrestaShop (specifically v1.7.5) one can get an instance of the module class by calling
$module = Module::getInstanceByName('theModuleName');
in the controller of a custom module.
Is 'theModuleName'
available via some other setting or variable or does it need to be hardcoded?
It should also be used as first parameter to getModuleLink().
回答1:
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;
}
}
来源:https://stackoverflow.com/questions/54469035/get-name-of-module-in-prestashop-front-controller