PrestaShop Overrides - 5 Reasons To Use

PrestaShop overrides allow you to make changes to PrestaShop core code, overriding default behaviour. Here's 5 reasons why this very is useful!

Using PrestaShop overrides rather than 'hacking the core' is very important. We recently looked at using PrestaShop module overrides as well as overriding PrestaShop controllers to use the latest version of jQuery from Google's CDN.

Using PrestaShop overrides you can create a completely bespoke ecommerce store using PrestaShop as it's foundation.

In these posts we touched upon the benefits of using PrestaShop overrides, but we will now run through the main reasons for this in more detail.

1. Keep your PrestaShop overrides when updating

If 'hack the core' and don't use PrestaShop overrides, all you changes and hard work will be overwritten as soon as you update your store.

For example, if you edited /controllers/ProductController.php directly, as soon as you update to the latest version of PrestaShop, these changes will be overwritten by a new /controllers/ProductController.php core file provided by the update.

By placing your changes in /overrides/controllers/ProductController.php as in our PrestaShop controller overrides tutorial, your changes will persist after an update.

2. Track your PrestaShop overrides

By having your PrestaShop overrides contained within their own files in the /overrides/ directory you're able to quickly see what has been edited and where.

Its not uncommon to make some significant changes to your PrestaShop store, then come back several months later and have completely forgotten what changes you had made and where.

Additionally, make sure you comment your code wherever possible too. You might understand what is happening now, but will you (or anyone) else a year from now?

3. Clean code

By keeping your changes seperate to the core code and following PrestaShop's coding conventions and structure your code is kept much cleaner.

Easier collaboration

Keeping your code clean and following PrestaShop's conventions also means that it's much easier to collaborate with other developers or PrestaShop store owners when customising your store.

This is especially useful if you're asking a question on the PrestaShop forums, the community will be much better equipped to help you and identify problems as your code will look familiar.

4. Advanced PrestaShop modules and multiple changes

Sometimes more advanced Premium modules will need to go beyond PrestaShop's module hook system and require you to add custom code and overrides to your store.

These changes are often well documented, and almost certainly always use PrestaShop's override system.

If you also use PrestaShop's overrides this means that your changes will work in harmony with any additional changes required by module developers on modules you have purchased.

If you were to edit the core files, this could lead to conflicts in the two changes and unexpected results as the PrestaShop module developer will have expected the core files to be untouched.

5. Seasonal Modules

PrestaShop module overrides work in a different way to PrestaShop class/controller overrides.

They are based on your active PrestaShop theme, and by overriding the module rather than editing it directly, you can apply changes to the module only when that theme is active.

Therefore, if you switch themes, your store will 'forget' the changes you had made.

This is especially useful for instance if you make changes to your modules for a seasonal theme, such as Christmas PrestaShop theme.

Conclusion

If you are comfortable enough coding to make these changes, you should be using PrestaShop overrides as the benefits. There are many benefits that outweigh the very small learning curve involved.

To conclude, use PrestaShop overrides. Many months from now, you'll be glad you did.