g.garrido Posted July 8, 2019 Share Posted July 8, 2019 Hello there, version 1.7.3.4 here. I need to change the behavior of the CategoryController so it changes the template on certain categories. It's working as long as I override it but I'm reading that overrides are not recommended in the long term. I'm trying to make a module in order to do that but I have no clue of where to start. I just need to change the initContent function. Can you help me guys? Link to comment Share on other sites More sharing options...
hexadog Posted July 31, 2019 Share Posted July 31, 2019 Hi, did you find a way to do it ? I'm facing the same issue. I need to extends CategoryController and I don't find a way to get it works with PS1.7. I'm creating a module with the following file: /override/controllers/front/CategoryController.php but the file is not copied into /override folder of prestashop when installing the module. I guess it's because overriding will be deprecated soon. I can't find any hook related to my need (I'm trying to customize the way products are ordered when displaying a specific category). Regards Link to comment Share on other sites More sharing options...
Apar Posted August 2, 2019 Share Posted August 2, 2019 Check this prestashop documentation for overriding the core files. https://devdocs.prestashop.com/1.7/modules/concepts/overrides/#class-controller-override Link to comment Share on other sites More sharing options...
hexadog Posted August 2, 2019 Share Posted August 2, 2019 hi, thanks I read it already but when installing my module override files are not copied into /override folder and so my custom controller are not called. Am I missing some configuration to tell prestashop to deploy mh custom controllers ? Link to comment Share on other sites More sharing options...
Apar Posted August 2, 2019 Share Posted August 2, 2019 I don't think you need any extra configuration for overriding. You just need to follow the correct folder structure and file name. Could you share your custom controller file and folder structure. Link to comment Share on other sites More sharing options...
Krystian Podemski Posted August 2, 2019 Share Posted August 2, 2019 PrestaShop has mechanism similar to wordpress template hierarchy, if you'll create file, for example category-3.tpl, this file will be loaded instead of category.tpl, this is a great feature but not many people knows about it Link to comment Share on other sites More sharing options...
Apar Posted August 2, 2019 Share Posted August 2, 2019 23 minutes ago, Krystian Podemski said: PrestaShop has mechanism similar to wordpress template hierarchy, if you'll create file, for example category-3.tpl, this file will be loaded instead of category.tpl, this is a great feature but not many people knows about it Prestashop has this kind of hidden feature too. Link to comment Share on other sites More sharing options...
hhennes Posted August 2, 2019 Share Posted August 2, 2019 (edited) Hi, An issue is open on github about this : https://github.com/PrestaShop/PrestaShop/issues/14948 For now the solution is to move manually the file Regards, Edited August 2, 2019 by hhennes (see edit history) Link to comment Share on other sites More sharing options...
hexadog Posted August 2, 2019 Share Posted August 2, 2019 5 hours ago, hhennes said: Hi, An issue is open on github about this : https://github.com/PrestaShop/PrestaShop/issues/14948 For now the solution is to move manually the file Regards, Thank you, it's exactly my issue. CategoryController is inside front/listing folder. I'll try creating /override/front/listing folder manually before installing and enabling module and see if it's working. Link to comment Share on other sites More sharing options...
hexadog Posted August 2, 2019 Share Posted August 2, 2019 I confirm that creating /override/front/listing folder before installing module works. My workaround (waiting issue solved by Pretashop) is to add the following code within the install function of my module: public function install() { // FIX: PS1.7 not copying files within controllers/front/listing directory if(!file_exists(_PS_OVERRIDE_DIR_ . 'controllers/front/listing')) { mkdir(_PS_OVERRIDE_DIR_ . 'controllers/front/listing', 0755, true); } ... } 1 Link to comment Share on other sites More sharing options...
Ali Samie Posted July 18, 2022 Share Posted July 18, 2022 Thanks @hexadog it helped me to solve this. I wonder why after two years Prestashop has this problem and it is not solved yet. 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