Jump to content

Override controller of module is it possible or not ?


missill

Recommended Posts

Hi everybody,
 
I'd like to override a whole module like "productcomments" module but i don't know how to do.
I read official documentation and forum posts about overriding but nothing speaks about the overriding of whole module.
 
I tried to override productcomments controller with path "modules/productcomments/controllers/front/default.php thanks to 3 folders possibilities but nothing working even if i delete cache/class_index.php.
 
- override/modules/productcomments/controllers/front/default.php
- themes/mytheme/modules/productcomments/controllers/front/default.php
- modules/productcomments/override/controllers/front/default.php
 
I'd like to have an expert answer about overriding module's controller to know if it's possible. I passed too many hours to try and know about it without success. My prestashop version is 1.6.1.7. 
 
Thanks for helping me.
 
Alex.

 

 

Link to comment
Share on other sites

Hi Alex,

 

I think it is possible and you should go with the first possibility:

 

override/modules/productcomments/controllers/front/default.php

 

but then, in default.php your file should start with:

 

class ProductCommentsOverride extends ProductComments {

 

to correctly override the default module behaviour.

I hope this will help.

 

Have a nice day,

Federica

Link to comment
Share on other sites

Hi and thanks Federica for your answer.
I already tried this possibility but without success.
Here si the declaration of override/modules/productcomments/controllers/front/default.php that i did :

// Include Module
include_once(dirname(__FILE__).'/../../productcomments.php');
// Include Models
include_once(dirname(__FILE__).'/../../ProductComment.php');
include_once(dirname(__FILE__).'/../../ProductCommentCriterion.php');

class ProductCommentsDefaultModuleFrontControllerOverride extends ProductCommentsDefaultModuleFrontController
{
...
} 

Original file is :

// Include Module
include_once(dirname(__FILE__).'/../../productcomments.php');
// Include Models
include_once(dirname(__FILE__).'/../../ProductComment.php');
include_once(dirname(__FILE__).'/../../ProductCommentCriterion.php');

class ProductCommentsDefaultModuleFrontController extends ModuleFrontController
{
...
}

I tried also to remplace these includes with new override path but not working.

Nobody tried to override this module or another ?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...