VTAdrien Posted June 22, 2017 Share Posted June 22, 2017 Hello, I'm new Prestashop Customer and I have question about Override Controller. I have this addons: https://addons.prestashop.com/en/private-sales-flash-sales/16634-advanced-private-sales-16-15.html I need to add JS file on this addons, so I think I need to Override the Front Controller to make: $this->addJS(...) The default file path is: root/modules/privatesales/controllers/front/home.php "class PrivatesaleshomeModuleFrontController extends ModuleFrontController" So, I did this: root/override/modules/privatesales/controllers/front/home.php "class PrivatesaleshomeModuleFrontControllerOverride extends PrivatesaleshomeModuleFrontController" I deleted the file "class_index.php" but It doesn't work..:/ I don't know if I forgot something.I have followed this documentation: http://build.prestashop.com/howtos/module/how-to-override-modules/ Can someone help me ? Thank you. Have a good day. Link to comment Share on other sites More sharing options...
joseantgv Posted June 22, 2017 Share Posted June 22, 2017 (edited) En 22/6/2017 a las 11:21 AM, VTAdrien dijo: Hello, I'm new Prestashop Customer and I have question about Override Controller. I have this addons: https://addons.prestashop.com/en/private-sales-flash-sales/16634-advanced-private-sales-16-15.html I need to add JS file on this addons, so I think I need to Override the Front Controller to make: $this->addJS(...) The default file path is: root/modules/privatesales/controllers/front/home.php "class PrivatesaleshomeModuleFrontController extends ModuleFrontController" So, I did this: root/override/modules/privatesales/controllers/front/home.php "class PrivatesaleshomeModuleFrontControllerOverride extends PrivatesaleshomeModuleFrontController" I deleted the file "class_index.php" but It doesn't work..:/ I don't know if I forgot something. I have followed this documentation: http://build.prestashop.com/howtos/module/how-to-override-modules/ Can someone help me ? Thank you. Have a good day. You can't override a module controller. EDIT: In PS 1.7 it's possible to override module controllers Edited March 10, 2020 by joseantgv (see edit history) Link to comment Share on other sites More sharing options...
VTAdrien Posted June 22, 2017 Author Share Posted June 22, 2017 (edited) Hi, Thank you for answer. Really ? So what is the purpose of this documentation then: http://build.prestashop.com/howtos/module/how-to-override-modules/ ? If I can't override module controller, do you have solution to add JS file for this module ? Like « blocksearch/blocksearch.js » or something ? Edit: and this https://www.prestashop.com/forums/topic/455661-override-a-module-frontcontroller/ ? .. Ty. Edited June 22, 2017 by VTAdrien (see edit history) Link to comment Share on other sites More sharing options...
VTAdrien Posted June 22, 2017 Author Share Posted June 22, 2017 Resolved. Thanks anyway Link to comment Share on other sites More sharing options...
joseantgv Posted June 22, 2017 Share Posted June 22, 2017 Hi, Thank you for answer. Really ? So what is the purpose of this documentation then: http://build.prestashop.com/howtos/module/how-to-override-modules/ ? If I can't override module controller, do you have solution to add JS file for this module ? Like « blocksearch/blocksearch.js » or something ? Edit: and this https://www.prestashop.com/forums/topic/455661-override-a-module-frontcontroller/ ? .. Ty. You can override module class, but not module controllers/classes. Resolved. Thanks anyway It would be great if you could say the solution you've taken Link to comment Share on other sites More sharing options...
razaro Posted June 22, 2017 Share Posted June 22, 2017 @joseantgv yeah I had similar link from same user that made override so it would be possible to override module controller https://www.prestashop.com/forums/topic/480523-override-front-controller-of-modules/?p=2267119 @VTAdrien Do share solution you found. Link to comment Share on other sites More sharing options...
VTAdrien Posted June 22, 2017 Author Share Posted June 22, 2017 Hi, It's wonderful to hear that ... I'm a professional developer, I guess you too? The solution doesn't seem insurmountable to find. Anyway, thank you for your helping. My solution: I created this file: root/override/modules/privatesales/privatesales.php with this content: <?php .. class PrivatesalesOverride extends Privatesales { ... public function hookDisplayHeader($params) { parent::hookDisplayHeader($params); $this->context->controller->addJS(_THEME_JS_DIR_.'modules/privatesales/js/privatesales.js'); } ... } ?> Don't forget to delete "cache/cache_index.php". I hope I can help some people Have a good day. 1 Link to comment Share on other sites More sharing options...
joseantgv Posted June 22, 2017 Share Posted June 22, 2017 @joseantgv yeah I had similar link from same user that made override so it would be possible to override module controller https://www.prestashop.com/forums/topic/480523-override-front-controller-of-modules/?p=2267119 @VTAdrien Do share solution you found. Well, but it's not possible without overriding core functions Link to comment Share on other sites More sharing options...
joseantgv Posted June 22, 2017 Share Posted June 22, 2017 Hi, It's wonderful to hear that ... I'm a professional developer, I guess you too? The solution doesn't seem insurmountable to find. Anyway, thank you for your helping. My solution: I created this file: root/override/modules/privatesales/privatesales.php with this content: <?php .. class PrivatesalesOverride extends Privatesales { ... public function hookDisplayHeader($params) { parent::hookDisplayHeader($params); $this->context->controller->addJS(_THEME_JS_DIR_.'modules/privatesales/js/privatesales.js'); } ... } ?> Don't forget to delete "cache/cache_index.php". I hope I can help some people Have a good day. When you ask help in a forum and you find a solution, the least you can do is share it to other users that could need it Link to comment Share on other sites More sharing options...
VTAdrien Posted June 22, 2017 Author Share Posted June 22, 2017 When you ask help in a forum and you find a solution, the least you can do is share it to other users that could need it I understand, it's not the problem but rather the way you approach things, politeness is optional in you? The ankles should not be swollen. I will not enter into any debate. Thanks for your help Link to comment Share on other sites More sharing options...
joseantgv Posted June 23, 2017 Share Posted June 23, 2017 I understand, it's not the problem but rather the way you approach things, politeness is optional in you? The ankles should not be swollen. I will not enter into any debate. Thanks for your help English is not my native language, so maybe it wasn't expressed as I wanted! 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