Jump to content

advice on overriding process function in Category Controller


larsodius

Recommended Posts

Hi all,

I have created an override in overrides/controllers/ for categoryController, thanks to some of the posts on here. I wanted to add some functionality to the process function. Basically, i extended the class, copied the original process function into my new file and added my changes. It works fine, just needs tidying up and some more validation.

Anyway, my question is - do I have to copy the entire process function (which seems like overkill) or is there someway to just add my functionality and call it at the appropriate time? I need it to run after we get the category products (see below) as I'm using the products it returns.

$cat_products = $this->category->getProducts((int)(self::$cookie->id_lang), (int)($this->p), (int)($this->n), $this->orderBy, $this->orderWay);

//my stuff here



Hopefully I'm making sense and someone can advise me.

Thanks.

Link to comment
Share on other sites

Thanks for that angora. Figured I'd have to overwrite it all most likely, but at 1.00am after a few hours getting to grips with prestashop you start to question the validity of everything. Slight pain if the core gets updated enough to change the process function....

Might look at the module/handle route as well, but for now overriding the function was relatively painless and is doing the job, so I'll leave that adventure for another day.

Thanks again.

Link to comment
Share on other sites

  • 2 weeks later...

I angora
Can I ask you a question?
In other CMS to override a file it's necessary only put a file with the same name in the override's folder, with prestashop it doesn't work, because if you copy ContactController.php in /override/controllers/ContactController.php, after appear an error that said
Fatal error: Cannot redeclare class ContactControllerCore in /var/www/prestashop1410/prestashop/override/controllers/ContactController.php on line 263
prestashop should controll this redeclaration

I want to override all that file how is it possible????

thanks

Link to comment
Share on other sites

Hi angora
I've found a good solution for the controllers override
You must only remove Core from the name of the class like
ContactControllerCore you must replace it with ContactController

byeeee

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