Prestashop 1.6 get instance of module class

2019-04-14 06:23发布

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条回答
ゆ 、 Hurt°
2楼-- · 2019-04-14 07:10
$abraSetDocs = Module::getInstanceByName('abra');

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

查看更多
登录 后发表回答