Prestashop: How to create admin controller to add link of module to backoffice menu

Troubleshoot: PrestaShop Admin Module Controller Not Found

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

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()

E.g. filename modules/module_name/controllers/admin/AdminProductarticleController.php

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();

Tools::redirectAdmin(Context::getContext()->link->getAdminLink(‘AdminModules’, true) . ‘&configure=nameofmodule&tab_module=front_office_features&module_name=nameofmodule’);
}
}

This entry was posted in troubleshoot and tagged . Bookmark the permalink.