Jontzzu Posted March 24, 2015 Share Posted March 24, 2015 Hello.I wonder what's goings wrong. I created plugin for custom order PDF invoices. I hooked new link in AdminOrders but I always get: "Controller not found" when I click link. (in my tpl file have this <a class="button" href="{$link->getAdminLink('[ControllerName]')|escape:'htmlall':'UTF-8'}"> )and my write controller in path: [mymodule]/controllers/admin/ControllerName.php: class Admin[ControllerName]Controller extends AdminControllerCore { }I tried extends ModuleAdminController, AdminController, it doens't work. I tried also ModuleAdmin[ControllerName]Controller and so on but it is not working. What is right way to make it?I have Prestashop version 1.5.6.1. Thanks Link to comment Share on other sites More sharing options...
NemoPS Posted March 25, 2015 Share Posted March 25, 2015 It should be ModuleAdminController like: class AdminpsTicketController extends ModuleAdminController the module in this case is psticket Link to comment Share on other sites More sharing options...
Jontzzu Posted March 25, 2015 Author Share Posted March 25, 2015 Not working.Let's assume that my module name is "mycustommodule"I have installed "mycustommodule" to store and it's have right location: "modules/mycustommodule"My module's main file is in location "modules/mycustommodule/mycustommodule.php". It's working properly. Every config settings working well. Then I hooked in Admin Order in "modules/mycustommodule/mycustommodule.php" and in template I have: <a class="button" href="{$link->getAdminLink('AdminmyCustomModuleController')|escape:'htmlall':'UTF-8'}&submitAction=generateInvoicePDF">Click this!</a>(link logic is copied in default/template/controllers/orders/helpers/view/view.tpl)Then I created new ModuleAdminController contoller to location: modules/mycustommodule/controllers/admin/AdminmyCustomModuleController.phpand content is: class AdminmyCustomModuleController extends ModuleAdminController { public function __construct() { parent::__construct(); } public function postProcess() { parent::postProcess(); exit; } public function initProcess() { parent::initProcess(); } public function processGenerateInvoicePdf() { Logger::AddLog("Test Test"); } } and AdminmyCustomModuleController functions copied in AdminPdfController.I don't know what I made wrong. Maybe it doesn't possible to extend ModuleAdminController? This is so confusing... Link to comment Share on other sites More sharing options...
Jontzzu Posted March 25, 2015 Author Share Posted March 25, 2015 (edited) I resolved the problem.In my view file which I hook in AdminOrder I add form and hide field "secretField" and I check if this secretField post-value is created in hookDisplayAdminOrder.Code in the module file: public function hookDisplayAdminOrder($params) { global $smarty; $this->_postkAdminProcess($params); if(isset($_POST['secretField']) && $_POST['secretField'] == "mySecretValue") { Logger::AddLog("It's working!"); } $smarty->assign( array('request_uri' => $_SERVER['REQUEST_URI']) ); return $this->display(__FILE__, 'admin_order.tpl'); } and in my admin_order.tpl file: <fieldset> <legend>[Title]</legend> <form action="{$request_uri}" method="post"> <input type="hidden" name="secretField" value="mySecretValue"> <input type="submit" value="Create pdf" > </form> </fieldset> I think it is not possible to extends ModuleAdminController... Edited March 25, 2015 by Jontzzu (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted March 27, 2015 Share Posted March 27, 2015 Actually, the only file name that works for me is without the word "controller', so in your case modules/mycustommodule/controllers/admin/AdminmyCustomModule.php Link to comment Share on other sites More sharing options...
Jontzzu Posted March 27, 2015 Author Share Posted March 27, 2015 (edited) Okey and how I can call to controller in AdminOrder? My module hooking AdminOrder and I have template where is link to {$link->getAdminLink('AdminmyCustomModule')|escape:'htmlall':'UTF-8'} | | v index.php?controller=AdminmyCustomModule&token=a7576e067c2a4d931a1806d6c568162f I try to send information to controller and create PDF. Edited March 27, 2015 by Jontzzu (see edit history) Link to comment Share on other sites More sharing options...
Jontzzu Posted March 27, 2015 Author Share Posted March 27, 2015 (edited) I don't know why but I cannot extend admin controllers. Then I tried to override AdminPdfController and it's doesn't work either. My only working solution is modifying Core code...Very stupid but no can do. Edited March 27, 2015 by Jontzzu (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted March 28, 2015 Share Posted March 28, 2015 It is possible actually, how did you do it? cleared cache? Link to comment Share on other sites More sharing options...
Jontzzu Posted March 28, 2015 Author Share Posted March 28, 2015 It is possible actually, how did you do it? cleared cache? I wonder what's goings wrong. I created plugin for custom order PDF invoices. I hooked new link in AdminOrders but I always get: "Controller not found" when I click link... Well I add new function (processMyCustomAction) to class "controllers/admin/AdminPdfController.php" and make request link to my modules AdminOrder hook: <a class="button" href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=myCustomAction&value1=a&value2=2">Click this</a> I never modify Core classes but now I don't have time to solve this problem. Maybe my customer previous prestashop developer make some configurations that modules cannot override admin classes and cannot make AdminModuleController child classes. I don't know... I usually found answer to my problems in google but it's first time when I can not solve the problem. Link to comment Share on other sites More sharing options...
Recommended Posts