PrestaShop allows you to override various components and behaviours. PrestaShop version 1.4 consists of two major points:
- The second is overridding software behaviour (class files and controller files) to target a specific section of the required components.
The modules are usually in the following format:
PrestaShop allows you to override or replace certain visible module files with new ones with the same theme. It couldn't be simpler, just do the following:
The new files will be used when you display your website.
Overriding is a way to "override" class files and controller files.
PrestaShop's ingenious class auto-loading function makes the "switch" to other files fairly simple.
Use inheritance to modify and add new behaviour using the various classes' properties and methods.
They are usually constructed the following way (product example):
This class would be called "ProductCore"
This controller would be called "ProductControllerCore"
You will need to create a file in the "override/classes/" folder to "override" the resulting class model such as:
This class would be called "Product" and spans the "ProductCore" class.
Just a flick of PrestaShop's magic wand and the spell is working!
You can also use this principle with the controllers and "override" in the following way:
This controller would be called "ProductController" and spans the "ProductControllerCore" class.
PrestaShop has certain folders you can use to override elements such as displaying redirections (_Tools.php) and measuring hook execution time (_Module.php) etc.
Example 1 :
Using data class MySQL.php is simply impossible while trying to type data into a database different from PrestaShop on the same MySQL Server. (Really!)
The solution is to use the following override of the MySQLCore class:
To use it you have to instanciate the class as follows:
- For local connection : new MySQL(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, 'DB_name', true);
- For remote connection : new MySQL(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, 'DB_name', true);
The last parameter forces the creation of a MySQL connection.
Example 2 :
Example 3 :
Example 4 :
Core files are not modified by overrideing. This technique allows you to personalise your PrestaShop boutique and monitor how the software evolves. Updates are facilitated.