Get name of module in PrestaShop front controller

后端 未结 2 520
伪装坚强ぢ
伪装坚强ぢ 2020-12-22 06:37

In PrestaShop (specifically v1.7.5) one can get an instance of the module class by calling

$module = Module::getInstanceByName(\'theModuleName\');

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-22 07:13

    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;
        }
    }
    

提交回复
热议问题