Recommended PrestShop Version

Thanks for choosing Agile.
For customers using our Agile Multiple Seller module and its accessry modules, we highly recommend to use PrestaShop 1.6x or 1.7.5 or lower. PrestaShop has made some changes in versions higher than 1.7.6 that makes it possible or very difficult to implement some of features via hooks, or override, since required hooks or override is not available.

Sept. 05, 2019

Class/Method conflict and code merge

When you install PrestaShop module/themes from different vendors, you may encounter errors like below that prevent you from installing the new module.
 
The following module(s) were not installed properly:
  • - agilemultipleseller : 
    The method getRootCategory in the class Category is already overriden.
 
Note: 
This is not a bug or an issue of the module. This is a limitation of PrestaShop class/method override specification. All classes and methods are only allow  override one time. For example, if your TV has only one HDMI input port and the port has been used by other device (like DVD player), and now you purchased new bluleray player also uses HDMI port too. You will find you are not able to connect the new blueray player to your TV because the only HDMI port has been used.   
 
What is class/method override?
PrestaShop provide an very 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/agilemultipleseller/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.
 
- We offer installation service for modules from us (addons-modules.com), that will include the potential code merge, if you need help, please contact us at [email protected]