Jump to content

Recommended Posts

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

  • 4 weeks later...

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

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

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

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

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

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);
        }

	...
}

 

  • Thanks 1
Link to comment
Share on other sites

  • 2 years later...

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