Overrides in PrestaShop: the great unknown

If you work with secure PrestaShop that more than once you've encountered a folder named override. Have you ever wondered to what are and how they work? Because in today's post we give keys so that you learn to use them and you can take maximum advantage of your PrestaShop store.
Alabaz
Actualizado: 20/10/2015 2818
Overrides in PrestaShop: the great unknown
Compartir:

If you have ever accessed the file structure of PrestaShop, you've seen a folder called "override".

This folder has been in our PrestaShop since ancient Mesopotamia (PrestaShop 1.4) but do we know what are the overrides and how they work?


An override (cancel, void) basically allows you to "rewrite" the operation a class of PrestaShop. We'll explain it better with an example:

Suppose that we want to make sure to deactivate a product, their stock is zero.

Then we can do an override of the part of PrestaShop is responsible for changing the State of a product and make part of change their status, also change the stock.

We just have to create a file with the same name of the class to overwrite in the same directory which is the original. In our example:


We have the original class at: /classes/Product.php

The override will be at: /override/classes/Product.php


The rest is already in the imagination of everyone.


Overrides of classes, starting with version 1.6.0.11, own modules and drivers can be.

In short, the overrides are used to add functionality or edit them a part of PrestaShop.

Many third party modules bring overrides to be able to properly perform its functions.

By what overrides instead of directly editing the files for PrestaShop?

The answer is simple: Compatibility and scalability.

In this way we maintain the part of the nucleus of intact PrestaShop, and all modifications in the override folder.

In addition, when upgrading PrestaShop, modifications would be lost if they were made on the own core.


Can two modules do an override on the same class?

Yes, but not the same method.

Two modules can be installed an override of Product.php but everything will go well only if not overwrite the same method. In this case, PrestaShop will give an error:

Unable to install with manual control: the method XXX in YYY group is now in manual control.

To install this second module, will be needed advanced knowledge of programming.

I have the override in place but is not why?

If we have PrestaShop 1.6 will have to go to advanced parameters > performance and make sure that the option "Disable the transients" is disabled, i.e. that them is not disabling.

If this step is correct and the override still perform their function, we must unleash our fury in the file class_index.php


This file can be found at /cache/class_index.php and is in charge of storing what kind has to override and what not. Delete the file class_index.php would suffice so that was generated a new one to refresh the page in the browser.


NOTE: If you use PrestaShop 1.6.0.9, surely will not be generated the file due to a bug in this version.

If you wish, you can contact with us so that you offer a solution. To do this you have to write a ticket by going to your personal space at AlabazWeb under the heading "Submit a ticket".


After all this, we already know what are these mysterious files that get into our PrestaShop and modify it according to our needs.


I hope you has been of help,

A greeting.

Buscar en el blog...
Más vistos
Síguenos en redes
0 comentarios

Escribe un comentario

¿Qué te ha parecido?