PrestaShop Admin Module Controller Not Found

浪尽此生 提交于 2019-12-08 06:42:58

问题


I am creating a controller into module folder and my module folder name is "productarticle" and my controller file "AdminProductarticleController.php" exist into path: "productarticle/controllers/admin".

The code of controller is mentioned below:

class AdminProductarticleController extends ModuleAdminController
{
    public function __construct()
    {
        echo Tools::getValue('id_product');
    }   
}

And I am trying to access this controller by using below URL:

http://myshost/admin/index.php?fc=module&module=productarticle&controller=AdminProductarticle&id_product=1&token=mytoken

But by using aforesaid URL showing below error:

Please tell me if I am doing anything wrong here.

Thanks in advance.


回答1:


Whenever this happened to me was because I hadn't created a menu entry for my new controller.

What I'd advise you to do is to go to Administration > Menus then created a new entry.

Fill in the form like this :

Name: Productarticle  
Class: AdminProductarticle  
Module: productarticle (if that's the name you gave your module)  
Active: NO (this way you don't have to have a menu entry that's gonna be useless to you)  

On top of that you should have something like this in your __construct()

class AdminProductarticleController extends ModuleAdminController
{
    public function __construct()
    {
        $this->module = 'productarticle'; //refers to your module's $this->name = 'productarticle';
        $this->bootstrap = true;
        $this->context = Context::getContext();
        //The following 2 lines are useful if you have to link your controller to a certain table for data grids
        $this->table = 'contribution';
        $this->className = 'Contribution';

        parent::__construct();
    }   
}

From this point onwards everything should be fine.



来源:https://stackoverflow.com/questions/37984270/prestashop-admin-module-controller-not-found

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