Question

I am trying to customize a third party module and I was wondering what is the general approach to doing so? (I'm assuming that I am not the only one who needs to modify a third party extension)

Currently I am just editing the files straight in the module and I had a feeling that there must be a better way.

  • Is there a way to override/make a higher priority file, instead of straight up editing the files?
  • How do you deal with module updates?
  • Do you try to minimise edits in the code by, for example, calling Models from your own extension?

I am just generally interested, because I cannot think of a pleasant approach to this.

Was it helpful?

Solution

  • Is there a way to override/make a higher priority file, instead of straight up editing the files?

For PHP classes, you have two possibilities, just as with core files:

  1. override in app/code/local. Magento uses the following priority for code pools (from lowest to highest):

    1. lib (third party libraries)
    2. app/code/core (Magento core code)
    3. app/code/community (Extensions)
    4. app/code/local (Project specific code)

    Note that some extensions install themselves in app/code/local which is wrong, but the only thing you can do about it, is to move the files and change the codePool line in app/etc/modules/Xxx_Yyy.xml

  2. Use the class rewrite system. This is the recommended way in Magento 1, and should always be preferred over code pool overrides if possible. Read more:

For templates and layout, use your theme as explained here: What is the correct way/approach to modify a Magento template? - for CSS, JavaScript and images (skin files), use your theme as well. Magento looks for these files in your theme first, then in the default theme (where the original module files are).

  • How do you deal with module updates?

With the approach outlined above, module updates are not a big problem. You have to check if the original files were modified and apply these modifications to your code as well. That means, the less you override, the easier the update. This is one advantage of class rewrites where you just override single method instead of copy the whole class.

  • Do you try to minimise edits in the code by, for example, calling Models from your own extension?

Yes, absolutely! Also I try not to copy and paste methods to change them, but call the parent method and add code before or after that if possible.

OTHER TIPS

Is there a way to override/make a higher priority file, instead of straight up editing the files ?

"We should not modified third party modules or extensions just like we don't modify core files."

code could by override exactly how we override core modules (Blocks,Models,controller, Helpers).

design& skin could be override by putting your modified files in your theme. (That is assume the third party modules you will put in based/default)

How do you deal with module updates?

Module update will provide the list of modified files. You need to check if those files override by you then need to merge those changes manually.

Do you try to minimise edits in the code by, for example, calling Models from your own extension?

If i understood you asking to use other module models in other module. As much as possible we should avoid doing that, still if we are doing so, then we should put the dependency tag in global XML file.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top