Hello everyone, today I’m very glad to guide you how to resolve the module conflicts. As you know, the conflict between modules in Magento is one of the most difficult and complex troubles to discover. So you’d surely be interested in this article below.

The most common conflict happens when two or more modules inherit a module core of Magento at the same time by using the command <rewrite> in the file config.xml of modules.

However, there are a large number of standard modules of Magento which have never had conflicts because Magento designs a plug-in mechanism in add-ons. For example: standard payment and shipping module.

 Useful Tip: Using Magento modules from different providers can cause more conflicts. Magestore’s here with over 60+ best modules for your Online Store. Checkout our extensions for Magento 1 and Magento 2 here. 

I – How do I identify extension conflicts?

In fact, we cannot find out the conflicts between templates. We can just discover the conflicts between modules. With the discovery of the extension conflict, there is a module that is being used at the moment.

https://www.magentocommerce.com/magento-connect/modules-conflict-detector.html

II – How do I resolve the conflicts?

There are 3 solutions to resolve the conflicts between modules.

Solution 1: Merge the code from a conflict file into the remaining and remove the part which is using <rewrite> in that file.

Solution 2: Remove <rewrite> in the config.xml of a module and let the conflict php file of this module inherit the php file of the rest.

For example: we have two modules Extension_A và Extension_B and they have conflicts.

  • At first we have:
class Extension_A extends Core_Class
class Extension_B extends Core_Class
  • We need to change into:
class Extension_A extends Extension_B
class Extension_B extends Core_Class
  • And then we remove the parts using <rewrite> that cause the conflict in Extension_B.

Solution 3: Use the depends module configuration in Magento.  We need to put the depends module configuration in app/etc/modules/extension_B.xml of Extension_B in order to define that the loading order of Extension_B is after the module Extension_A is loaded.

<config>
 <modules>
   <Extension_B>
      <depends>
          <Extension_A/>
      </depends>
   </Extension_B>
 </modules>
</config> 

Thus, the class of B module can still rewrite the class of the core (through the class of module B). We can use the class inheritance as below:

class Extension_B extends Extension_A
class Extension_A extends Core_Class

III- FAQs

Question: If there are two modules that rewrite a class, which module will be read by the system to run?

Answer: The module that is loaded the configuration first will be overwritten configuration by the next module if there is any duplications of the bar in the xml. The order of loading modules depends on the name of the configuration (depends) of modules as in the last post Fundamentals of the part one.

Well, now you find it far easier to solve the conflict between modules, don’t you?

Finally, you can do it yourself OR hire a Magento Developer for a best result.

Gook luck 😉 .

How to pass Magento certification exam

Author

Why Magestore? We believe in building a meaningful & long-term relationship with you.

Write A Comment