Resolve Magento Extension Conflicts!!

Published On: 3 January 2014.By .
  • Digital Engineering

One of the biggest problem in Magento is extension conflicts. Extension conflict comes in picture when two or more extensions overwrite same core class. When we define “” tag in extensions config.xml with the name of some core file which is used by other extension too. Then it may hits conflict with this extension.

We can avoid class rewrite using observers. But observer is useful only when we are satisfied with core methods and want to add some process in it. For example we need to save count of sale for each order item. In this we agree to save order just as Magento does but want to add one more thing in process. For that we can use observer. Which listen event called Mage_Sales_Order_Save_After and Update the sale count for each order item.

But when we Magento default process doesn’t fulfill the requirement and want to change or modify core functionality then we have to rewrite respective core class.

magento tips

Resolve Conflicts:

We have three ways to resolve extension conflicts.

Merge files from both extensions which rewrite the same core class and remove or comment rewrite code in config.xml of any one extension.

For example suppose we have two extensions A and B. A has controller class A_controller_ orderController and B has controller class B_controller_ orderController.
Code

And remove or comment rewrite code in config.xml of extension A.

In This method we have to merge both file in one. Just copy function of one class and paste in another one. Now resolve conflict in functions if we have same function in both. It is useful when we have conflicting methods in classes.

Make the Conflicting Php file extend the other extension file rather than core file.

For example: Suppose we have two class files.

As we see both file extends same core class. To avoid conflicts we can extend core class in one extension (A) and Other extensions (B) class file extends class file from A.

Like

Once you have done this you need to change extension B config.xml file commenting out the conflicting “” blocks that are now inheriting from A.

This method is useful when we have confliction methods in classes. In this we don’t need to copy all methods in another class just need to resolve conflict in methods which are in both classes.

Use the capability to make one extension depend on another. This defines the rewrite order.

Let’s say you have 2 extensions Auriga_A and Auriga_B. In the module for file Auriga_B (under app/etc/modules) you would add the following:

Now Magento will load the extensions in this order. So in effect the Auriga_B class will be loaded first, then Auriga_A, then base Magento.

This Method is only useful when we don’t have same method in classes.

Choice of method to resolve conflicts is base on how far we need to go. Mostly we have conflicts in class not in the actual methods within that class. In this scenario I’d go for option 3. If you have conflicting methods within classes then either option 1 or 2 is better.

Related content

That’s all for this blog

Go to Top