Your shopping cart is empty

How to fix problem like «The method X in the class X is already overridden» when installing a module?

This is not a bug or an issue of some module. This is the limitation of Prestashop installing system and overriding system.

When you install PrestaShop module/themes from different vendors, you may encounter errors like above that prevent you from installing the new module. Because all classes and methods are only allow override one time.

What is class/method override?

PrestaShop provide a flexible architecture for 3rd party vendors or store owners to extend the functionality and features by addons or modules or just simple modifications. The new addon features and functions will need to modify some behaviour of original PrestaShop class and method, This is implemented by class/method override.

All override class/methods are installed under following folders:

YourStoreRoot/override/classes/

YourStoreRoot/override/controllers/

Why override conflicts?

In the whole PrestaShop, you can have only one one override for each class or each method, and the override must be installed to the above folder. There are many theme vendors and modules vendors are developing themes and addons/modules. Some time they will override the same class and method. If that happens, the conflicts occurs. The first one install without a problem, but later one will not be able to installed because of the conflicts and PrestaShop installer will show the error message listed previously.

How to resolve the error?

In order to resolve the conflicts, you will have to merge override classes/methods which are in conflicts from both module/theme, then you can continue to install the modules again.

Caution. Code merge could be simple and could be very complicated, some time you have to read the code to understand the logic of code to see which piece of code needs to be tun first and which piece of code should be run after. If you do not understand PHP code and PrestaShop, it is better do not do the merge by yuorself. Otherwise you may break the code and make system not working properly.

Here is the basic steps to merge the files if you are able to do that by yourself.

Steps 1. Identify the file name and methods that are in conflicts.

The conflict could be common class or an page controller. You can tell from the class name part of the message. For example, following message indicate the class : Category, the method: getRootCategory

The method getRootCategory in the class Category is already overriden.

All page controllers file name always ends with "Controller.php", something like xxxxxxxController.php, for example CategoryController.php for category page.

Step 2. Merge the code.

We are using the same Category.php as an example.

To be merged file: /modules/somemodule/override/classes/Category.php - the module name will differ based on the module you are installing.

Destinationfile to merge code into: /override/classes/Category.php

Step 3. Rename class file which has been merged in the new installing module.

After you have merged the code into the installation destination file, you will need to rename the file that has been merged so that it will not be installed again.

You need to change the file name to anything else that does not end with .php,for example you can change to Category.php-org

Step 4 Repeat above Steps 1-3 for each conflicts class/method to reoleve them all.

Step 5. Try install again.

After you have finish merging all conflicts code, you can try again the installation, it should be able to install the module now.

Note: the right to override class/method are equal to all vendors (theme/modules vendors). all vendors should be treated fairly.