kalle@makewebo Posted November 3, 2015 Share Posted November 3, 2015 Hi! In the process of updating Prestashop so we can use module overrides. But I can't find anything about how to override a modules front controller behaviour. Is it possible and then how? I have checked the documentation but sadly Prestashop documentation is just awful. Google doesn't give me anything either which is odd. Best Regards Kalle Link to comment Share on other sites More sharing options...
razaro Posted November 5, 2015 Share Posted November 5, 2015 Check this http://build.prestashop.com/howtos/module/how-to-override-modules/ and http://nemops.com/override-prestashop-modules-core/#.VjshSXyrTIo Link to comment Share on other sites More sharing options...
kalle@makewebo Posted November 5, 2015 Author Share Posted November 5, 2015 Check this http://build.prestashop.com/howtos/module/how-to-override-modules/ and http://nemops.com/override-prestashop-modules-core/#.VjshSXyrTIo Thanks for taking the time. Two good guides but they don't explain what I'm asking. For instance what I want to know is if there is a way to override a modules front controller. Files that are under: modules/your_module/controllers/front/my_front_controller.php. In order to make it (easier) to update Prestashop and modules without having to worry about possible changes in core files. A simple module override you just add "Override" at the end of your class and put the .php file in your override folder. Is it the same way with controllers of a module? Link to comment Share on other sites More sharing options...
razaro Posted November 5, 2015 Share Posted November 5, 2015 Sorry my bad, you clearly said module front controller. Not sure that possible right now. If you check these changes https://github.com/PrestaShop/PrestaShop/pull/2133/files think it is just for main module php file. And think adding Override to module front controller and placing it in right override folder would not work. Think it needs changes in core files. Link to comment Share on other sites More sharing options...
kalle@makewebo Posted November 5, 2015 Author Share Posted November 5, 2015 Sorry my bad, you clearly said module front controller. Not sure that possible right now. If you check these changes https://github.com/PrestaShop/PrestaShop/pull/2133/files think it is just for main module php file. And think adding Override to module front controller and placing it in right override folder would not work. Think it needs changes in core files. Yeah, seems like you are correct. That was really too bad. Maybe it's possible to cook something up by myself to get it to work. But that will have to be a project for the future. Thanks so much for taking the time to help out Link to comment Share on other sites More sharing options...
alexdee2007 Posted February 23, 2016 Share Posted February 23, 2016 Put this file into override/classes/. Then delete cache/class_index.php This allow override front controller of modules. Example: override/modules/productscomment/controllers/front/default.php class ProductCommentsDefaultModuleFrontControllerOverride extends ProductCommentsDefaultModuleFrontController { .............. } Tested on PS 1.6.1.4 Sorry for my bad english. Best regards, Alex. Dispatcher.zip 5 Link to comment Share on other sites More sharing options...
razaro Posted February 23, 2016 Share Posted February 23, 2016 Hi Alex Thank you for code and your contribution. Will test it out later. And you should create new topic about this and also try to get this to Prestashop team on github, would be nice to have in next versions. Link to comment Share on other sites More sharing options...
kalle@makewebo Posted February 24, 2016 Author Share Posted February 24, 2016 Put this file into override/classes/. Then delete cache/class_index.php This allow override front controller of modules. Example: override/modules/productscomment/controllers/front/default.php class ProductCommentsDefaultModuleFrontControllerOverride extends ProductCommentsDefaultModuleFrontController { .............. } Tested on PS 1.6.1.4 Sorry for my bad english. Best regards, Alex. Thank you so much for this. It worked like a charm. This will make it easier to update modules. You saved a lot time for many users with this. Link to comment Share on other sites More sharing options...
alexdee2007 Posted February 25, 2016 Share Posted February 25, 2016 Thank you so much for this. It worked like a charm. This will make it easier to update modules. You saved a lot time for many users with this. Happy to help. I did it for their own needs, I'm glad that was useful to others. Best regards, Alex. 1 Link to comment Share on other sites More sharing options...
alexdee2007 Posted February 29, 2016 Share Posted February 29, 2016 Just in case. If you need override Admin Controller of modules, i have been made some changes in file Dispatcher.php. Also you need put file AdminController.php into override/classes/controller Then delete cache/class_index.php This allow override front and admin controllers of modules. Best regards, Alex. override.zip 5 Link to comment Share on other sites More sharing options...
kalle@makewebo Posted March 1, 2016 Author Share Posted March 1, 2016 Just in case. If you need override Admin Controller of modules, i have been made some changes in file Dispatcher.php. Also you need put file AdminController.php into override/classes/controller Then delete cache/class_index.php This allow override front and admin controllers of modules. Best regards, Alex. Awesome! Thanks once again, it's great. Link to comment Share on other sites More sharing options...
[email protected] Posted April 8, 2016 Share Posted April 8, 2016 Thanks for sharing it. I will give a try. Link to comment Share on other sites More sharing options...
SipTech411 Posted July 11, 2017 Share Posted July 11, 2017 Just in case. If you need override Admin Controller of modules, i have been made some changes in file Dispatcher.php. Also you need put file AdminController.php into override/classes/controller Then delete cache/class_index.php This allow override front and admin controllers of modules. Best regards, Alex. This doesn't work for me on PS 1.6.1.4 Link to comment Share on other sites More sharing options...
JavierEsK Posted January 19, 2018 Share Posted January 19, 2018 (edited) En 29/2/2016 a las 8:20 PM, alexdee2007 dijo: Just in case. If you need override Admin Controller of modules, i have been made some changes in file Dispatcher.php. Also you need put file AdminController.php into override/classes/controller Then delete cache/class_index.php This allow override front and admin controllers of modules. Best regards, Alex. override.zip Great, it works perfectly, even with current versions of Prestashop, thanks so much. Edited January 19, 2018 by JavierEsK (see edit history) 1 Link to comment Share on other sites More sharing options...
vcopleutre Posted April 17, 2019 Share Posted April 17, 2019 Works perfectyle, thank you Link to comment Share on other sites More sharing options...
pemasem Posted August 7, 2019 Share Posted August 7, 2019 My version is: 1.6.1.24 I'm trying to override this class: mywishlist.php class BlockWishListMyWishListModuleFrontControllerOverride extends BlockWishListMyWishListModuleFrontController { public function ajaxProcessDeleteList() { die(Tools::jsonEncode(array('success' => "false"))); } } I've used all this path but it doesn't work in any of them: /override/classes/mywishlist.php /override/classes/module/mywishlist.php /override/classes/module/blockwishlist/mywishlist.php /override/classes/module/blockwishlist/controllers/front/mywishlist.php /override/modules/mywishlist.php /override/modules/blockwishlist/mywishlist.php /override/modules/blockwishlist/controllers/front/mywishlist.php You can test it doing this accessing by his url: /module/blockwishlist/mywishlist?rand=1565169640797&deleted=1&myajax=1&id_wishlist=1&action=deletelist&_=1565169634464 It should return {"success":"false"} Please, can somebody help me? Its frustrating.... Thank you in advance !! Link to comment Share on other sites More sharing options...
Shonen Posted October 19, 2022 Share Posted October 19, 2022 Still work like a charm in Prestashop 1.7.8.5 for override/modules/my_module/controllers/front But does not work for admin, as your AdminController I put in override/classes/controller load another admin theme (new-theme instead of default). Yet great workaround thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now