未找到 PrestaShop 管理模块控制器 [英] PrestaShop Admin Module Controller Not Found
问题描述
我正在模块文件夹中创建一个控制器,我的模块文件夹名称是productarticle",我的控制器文件AdminProductarticleController.php"存在于路径:productarticle/controllers/admin"中.
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".
控制器代码如下:
class AdminProductarticleController extends ModuleAdminController
{
public function __construct()
{
echo Tools::getValue('id_product');
}
}
我正在尝试使用以下 URL 访问此控制器:
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.
提前致谢.
推荐答案
每当我遇到这种情况时,都是因为我没有为我的新控制器创建菜单项.
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.
像这样填写表格:
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)
最重要的是你应该在你的__construct()
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.
这篇关于未找到 PrestaShop 管理模块控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!