Search code examples
prestashopprestashop-modules

Override template


I am looking to create a module for a customer, but I have to override the product_variants.tpl from the prestashop classic theme.

I have two questions:

  • Is there any way to override it without edit the original file? Should I need to create a copy of the entire theme or is there a cleanest solution?

  • If I will override that file and my customer would like to change the classic theme with another one, I have to change the override again because the file will probably have another name and not 'product_variants.tpl', right? Is there a modular way to do this?

Thanks in advance!


Solution

  • There is no officially way to override the core template files of the theme from module. The best way is to create a child theme, and override only the files you need. https://devdocs.prestashop.com/1.7/themes/reference/template-inheritance/parent-child-feature/

    The answer to the second question is yes. And it works correctly, because each theme has its own structure, and it's possible that the modifications you've made to the old theme might cause the new theme to not work properly.