gowri Posted November 13, 2013 Share Posted November 13, 2013 (edited) How to Override a same method in admin order controller by several Modules in prestashop 1.5 example i need to override a postprocess method in admin order controller by two different custom modules. help me please Thanks in Advance Edited November 20, 2013 by gowri (see edit history) 1 Link to comment Share on other sites More sharing options...
NemoPS Posted November 13, 2013 Share Posted November 13, 2013 In your module's folder, create a subfolder named override. Inside this, the following structure: controllers/admin/ Add your overrides inside Be sure you follow the naming conventions as specified in the official docs! 1 Link to comment Share on other sites More sharing options...
gowri Posted November 13, 2013 Author Share Posted November 13, 2013 Hi Nemo1, I already do controller override by module, that is not an issue. i just asked how to override a method (ie function) in admin order controller by several modules in prestashop 1.5. Thank you For your Response.. Link to comment Share on other sites More sharing options...
NemoPS Posted November 13, 2013 Share Posted November 13, 2013 Well, you can simply create the same method in the override controller, is this what you are asking? If you mean overriding by different modules at the same time, this cannot be done Link to comment Share on other sites More sharing options...
gowri Posted November 14, 2013 Author Share Posted November 14, 2013 Hi Nemo1, Yes, overriding the same method (ie. postprocess()) in admin order controller by different modules. anyone please suggest me the solution. Thanks in advance. Link to comment Share on other sites More sharing options...
NemoPS Posted November 14, 2013 Share Posted November 14, 2013 There is no solution, you can only have one override for the same method, at the same time ;( Link to comment Share on other sites More sharing options...
vekia Posted November 14, 2013 Share Posted November 14, 2013 if you use two the same modules at the same time, why not to create one override with modification for both of them? Link to comment Share on other sites More sharing options...
gowri Posted November 15, 2013 Author Share Posted November 15, 2013 Hi Vekia, First of all Thanks for your response. Yes. You are right, but the modules are for different purpose,and the method (ie postprocess()) in admin order controller is used for both of the modules. So while installing the second module, i got the error as "Unable to install Override : The Method postprocess() in the class AdminOrdersController is already overridden". I want to get clear in two points, 1. If we use the same method for override in a controller from different modules, what is the exact solution ? 2. for postprocess() in adminordercontroller, is there any possible alternate method to use? If possible Please reply me... Thanks in advance Link to comment Share on other sites More sharing options...
vekia Posted November 15, 2013 Share Posted November 15, 2013 1) there is no way to use two overrides as Nemo1 stated above. 2) what kind of code you want to use? i convinced that you can create only one override, which will be used by two separate modules. Link to comment Share on other sites More sharing options...
gowri Posted November 15, 2013 Author Share Posted November 15, 2013 (edited) Hi Vekia, Thanks for your reply... I agree with (1) there is no way to use two overrides as Nemo1 stated above.) your valid point. Now i'll explain you what i exactly want... Module - 1. I have to create a module for "generate a copy of an existing order". I placed a form with button .- (Generate copy Order) Using "displayAdminOrder" hook. After submitting this form i need to regenerate a copy of order. Module -2. I Placed a form with button "Undelivered Return Reason (by carrier)" using "displayAdminOrder" hook. For Both these modules we are using postprocess() method in admin order controller override. This is the concept of my question. Please give me some solutions. Thanks in advance.. Edited November 15, 2013 by gowri (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 15, 2013 Share Posted November 15, 2013 what about something like: public function postProcess(){ if (Tools::isSubmit('module_1_settings')){ // do something } if (Tools::isSubmit('module_2_settings')){ // do something } } Link to comment Share on other sites More sharing options...
gowri Posted November 16, 2013 Author Share Posted November 16, 2013 (edited) Hi Vekia, Thanks for your reply.. the exact output we need is what you presented in your previous conversation. Now i'll explain in detail below, Module -1 : Path: localhost/testshop/modules/custommodule1/override/controllers/admin/AdminOrdersController.php In AdminOrdersController.php we are using the below code format in custommodule1. class AdminOrdersController extends AdminOrdersControllerCore { public function postProcess() { if (Tools::isSubmit('module_1_settings')){ // do something } } } First i have installed this customemodule1, So in the path, Path : localhost/testshop/override/controllers/admin/AdminOrderscontroller.php AdminOrdersController.php file get override with the below output class AdminOrdersController extends AdminOrdersControllerCore { public function postProcess() { if (Tools::isSubmit('module_1_settings')){ // do something } } } Module -2 : Path: localhost/testshop/modules/custommodule2/override/controllers/admin/AdminOrdersController.php In AdminOrdersController.php we are using the below code format in custommodule2. class AdminOrdersController extends AdminOrdersControllerCore { public function postProcess() { if (Tools::isSubmit('module_2_settings')){ // do something } } } While installing the second module, i get the error in Modules list page as below, "Unable to install Override : The Method postprocess() in the class AdminOrdersController is already overridden". the printscreen is attached below. Kindly check it. Please tell me the solution...Thanks in advance.. Edited November 16, 2013 by gowri (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 16, 2013 Share Posted November 16, 2013 i suggested to create only one override with functions for your two modules If you want to use these modules in one shop, it will not be a problem. so, only one override with: Module -1 : Path: localhost/testshop/modules/custommodule1/override/controllers/admin/AdminOrdersController.php In AdminOrdersController.php we are using the below code format in custommodule1. class AdminOrdersController extends AdminOrdersControllerCore{public function postProcess(){if (Tools::isSubmit('module_1_settings')){// do something} if (Tools::isSubmit('module_2_settings')){// do something}}} 1 Link to comment Share on other sites More sharing options...
gowri Posted November 18, 2013 Author Share Posted November 18, 2013 Hi Vekia, Thanks for your response, and thanks for the information you have given. it is very helpful for me to complete my work. Link to comment Share on other sites More sharing options...
addon.vivek Posted February 12, 2014 Share Posted February 12, 2014 Hello friends , I have a issue in creating custom module for backoffice. I created one classes folder for Add button (mycustommodule/classes/Redirect.php) when i press the add button it says Redirect class is not found. Please help me......... Link to comment Share on other sites More sharing options...
Recommended Posts