Get Free Audit

Override In Prestashop

Aug 14, 2013

1245 Alex Simonchik

Override In Prestashop

Introduction

Very often users find default Prestashop functionality quite insufficient. At the same time, although you can expand the functionality by making changes in core files, later you may have some difficulties since you will not be able to update your Prestashop version and buying new modules and addons can become a nightmare for you, because the modified part of the system may not run after you install a new module. There is a special method called override which helps to solve this type of problem. So, what is override? This is a mechanism which allows you to change behavior of different functions without changing Prestashop core files themselves. Let’s see how it works: as we have previously described, the collector Autoloader gathers classes’ files. It is searching for files as follows:

  • classes/
  • override/classes/
  • controllers/
  • override/controllers/

In other words, if your class is located in the override folder, instead of the standard file your customized file will be used, which as a rule has been inherited from the default core class.

Overriding classes

The file Classes/Autoload.php is responsible for the order of loading files and the function generateIndex() contains the logic for loading classes.

Overriding modules’ tpl files

To make changes into a module’s tpl file there is no need to change the file itself. All you need is to use the advantages of the override method and place the modified file into the folder with your frontend theme. For example, to override the file blockwishlist/blockwishlist.tpl you need to create this file: themes/your_theme/modules/blockwishlist/blockwishlist.tpl

Overriding admin panel themes

override/controllers/admin/templates – this is the folder where you can place modified admin theme files. If you want to replace an admin theme file in your own module – there is no such automatic collector as used for classes (see the section “ How to make override in your own module” the function instаllOverrides()). There is no such possibility for a frontend theme as to overload a theme.

If you generate forms using the Helper class, please, note the function Helper::createTemplate()

Igor Dragun
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Igor


How to do override in admin panel – http://belvg.com/blog/overloading-a-template-in-your-admin-panel-controller.html

How to do override in your module – http://belvg.com/blog/how-to-make-an-override-in-your-module.html

Igor Dragun
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Igor

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *