PrestaShop Module Overrides Tutorial

How to use PrestaShop module overrides to customise PrestaShop modules without editing core code, so changes will be kept after updating.

PrestaShop 1.4 allows ecommerce merchants and developers to make changes to their store the ability to override PrestaShop modules, controllers and classes rather than editing PrestaShop's core.

In simple terms, this means that your changes will not be overwritten when you update PrestaShop to the latest version, giving you peace of mind and saving you a lot of hassle. There are also many other benefits we looked at in another post.

We previously looked at using PrestaShop controller overrides to use Google's CDN hosted jQuery, but what if you simply wanted to change a few things in a PrestaShop module?

PrestaShop Modules tab in back office

How PrestaShop Module Overrides Work

PrestaShop module overrides are achieved by editing duplicates of the module's template (.tpl) file within your themes folder.

Your PrestaShop module overrides are located in /themes/_themename_/modules/ (where themename is the name of your active theme). If the folder doesn't exist, create it.

An Example PrestaShop Module Override

In our simple example we're going to change a couple of bits of text in the 'Specials' block module in the side bar.

PrestaShop Module Block Specials

Quick Note: This article was written for PrestaShop 1.4. There may be _very slight differences regarding line numbers if you're using a later version of PrestaShop. Please adapt as necessary._

1. Copy the PrestaShop module's .tpl file

First, you'll need to copy the .tpl file of the PrestaShop module that you want to override.

Go to /modules/blockspecials/ and copy blockspecials.tpl

Create a new folder in /themes/_themename_/modules/ called blockspecials and copy the blockspecials.tpl inside.

PrestaShop Modules Override Folder

You should now have a file a copy of blockspecials.tpl inside the modules folder inside your active theme's folder, as shown above.

2. Open and edit the copied .tpl file

Open the new blockspecials.tpl file in your favourite text editor and scroll to line 29:

<h4><a href="{$link->getPageLink('prices-drop.php')}" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'}</a></h4>

This is the title of the specials block module. We're going to change this very slightly, giving it a new title as follows:

<h4><a href="{$link->getPageLink('prices-drop.php')}" title="{l s='Deal of the day' mod='blockspecials'}">{l s='Specials' mod='blockspecials'}</a></h4>

We've changed the title from Specials to Deal of the day.

Now go to line 51 and you'll see:

<a href="{$link->getPageLink('prices-drop.php')}" title="{l s='All specials' mod='blockspecials'}">{l s='All specials' mod='blockspecials'}</a>

Lets change this to:

<a href="{$link->getPageLink('prices-drop.php')}" title="{l s='Our other deals' mod='blockspecials'}">{l s='All specials' mod='blockspecials'}</a>

This will change the button text at the bottom of the block from All specials to Our other deals

3. See your changes

Save and upload your changes to your PrestaShop store's web server.

Refresh your page (you may need to refresh by pressing ctrl+f5) and you should now see our changes take effect.

PrestaShop Module Override Block Specials

If you can't see your changes, make sure that you have turned off PrestaShop's performance options temporarily.

Customise your PrestaShop Modules

This is a very simple example, but it demonstrates the customisations possible by using PrestaShop module overrides.

Rather than simply changing a title or some button text, you could completely rework the structure or functionality of a PrestaShop module.

By using PrestaShop module overrides rather than editing the module directly and 'hacking the core', your changes will persist after updating to the latest version of PrestaShop.

Module overrides can be done to both 'core' PrestaShop modules, or modules purchased from PrestaShop Addons.

Let us know if this tutorial was useful to you, or if you have any questions regarding PrestaShop module overrides in the comments below!