Prestashop 1.6 get instance of module class

给你一囗甜甜゛ 提交于 2019-12-03 22:34:36

问题


I have an overridden class OrderConfirmationControllerCore.

I have a modul with class Abra.

I need to get an instance of Abra class in the OrderConfirmationControllerCore

My code is:

class OrderConfirmationController extends OrderConfirmationControllerCore
{
    public function init()
    {      
       $abraSetDocs = new Abra();
       parent::init();
    }
}

This generates error:

Fatal error: Class 'Abra' not found in /../override/controllers/front/OrderConfirmationController.php on line 39 

How can I get the instance of the class?


回答1:


$abraSetDocs = Module::getInstanceByName('abra');

Note that 'abra' is the name of the module ($this->name from the module __construct()), not the class name.



来源:https://stackoverflow.com/questions/28585399/prestashop-1-6-get-instance-of-module-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!