Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

We work with a large number of community extensions and frequently override their behavior with small extensions of my own. So far I've been using a naming convention of app/code/local/{MyCompany}_{OriginalnamespaceModulename} for my overrides, which is useful for clearly putting our modifications in one location.

However, I've also frequently seen where the original namespace and module name are re-used (e.g. the original module is app/code/community/{Namespace}_{Modulename} so the overriding extension is named app/code/local/{Namespace}_{Modulename}. This seems intuitive; except for when 3rd party extensions want to be installed to the local codepool. In our case we do have a fair number of 3rd party extensions in local, making it a bit of a goose chase to check if they are a "full" extension or just there for overriding a community extenion.

So what's the best practice? Is there anything wrong with my format of {MyCompany}_{OriginalnamespaceModulename}?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

This looks like "opinion based" to me so here is my opinion.

I don't think it's a good idea to keep the exact namespace and module name. You can end up with conflicts.
For example if you add a class in your module (local) with the same path and name as the original extension class (community)? Then your class will be used everywhere. Sometimes you want that but in most cases you don't (at least I don't).

I prefer putting everything on the same namespace (MyCompany) and use as module name NamespaceModulename - a concatenation of the original namespace and original module name.
This way you can have a clear view of which is which.

Of course this can lead to conflicts but the chance is slim.
Here is an example.
You have 2 community extensions:

  • Ns_ModName
  • NsMod_Name

Following the logic I described above both end up being overwritten in MyCompany_NsModName, but come on...what are the odds?

Also the most important thing you should do is to state your dependencies in the declaration files. (app/etc/modules/).
If you override the community extension called Namespace_Module to MyCompany_NamespaceModule make sure the file app/etc/modules/MyCompany_NamespaceModule.xml looks like this:

<?xml version="1.0"?>
<config>
    <modules>
        <MyCompany_NamespaceModule>
            <codePool>local</codePool>
            <active>true</active>
            <depends>
                <Namespace_Module/> <!-- add dependence on the original module -->
            </depends>
        </MyCompany_NamespaceModule>
    </modules>
</config>

This way you can easily identify what you extended and, in case you disable the original extension, Magento will tell you at runtime that you have an extension that depends on what you just disabled/deleted and you can disable your extension also.

share|improve this answer
    
I agree, and I also prefer using my company for the namespace (the changes are specific to my company--so why not). I was mostly curious because in a "perfect" world the local codepool would effectively be a namespace for my company's specific code--but that seems to go out the window with 3rd party extensions that install there instead of to the community pool. –  STW Apr 25 at 14:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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