4

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.

2
  • Your Magento version is 1.9 or 2? Commented May 2, 2017 at 12:16
  • Sorry, I didn't think that the general approach might have changed. I am using 1.9. (I will update the tags) Commented May 2, 2017 at 12:21

2 Answers 2

2
  • 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.

3

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.

2
  • Hmm, to override core files you create the same path in the app/code/local/ but third party modules are in the local directory already. Am I missing something? Commented May 2, 2017 at 12:13
  • write custom module to override your third party module. That is bit extra work but recommended Commented May 2, 2017 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.