Jump to content

[solved] Override Controller by custom module in 1.5


Recommended Posts

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.5Thank you For your Response..

Link to comment
Share on other sites

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

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...  :rolleyes:

 

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 by gowri (see edit history)
Link to comment
Share on other sites

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..

post-105673-0-71293300-1384576951_thumb.jpg

Edited by gowri (see edit history)
Link to comment
Share on other sites

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
}
}
} 

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
×
×
  • Create New...