0

One package1_Module1 extension is created and I want to make its addon of package1_Module1.

<depends> <Package1_Module1/> </depends>

this above code need in `app/etc/modules/Package1_Module2.xml` for `package1_Module1` extension addon ?

  • The question is about how to declare a dependency or about best practices? – MauroNigrele Feb 7 '16 at 20:10
  • I know if I declare depends tag so addon depended on package extension but I want to know that is it compulsory or need depends code in addon regsitration xml file ? – Niraj Patel Feb 7 '16 at 20:26
3

You should set as dependency just those modules that need some code and/or data/attributes created by other modules.

So lets say that the module My_ModuleA declare a helper My_ModuleA_Helper_Data and Other module Your_ModuleA has a helper that extends My_ModuleA_Helper_Data, in this case you should declare that dependency.

Another valid case would be if My_ModuleA creates a product attribute custom_sarasa_id and My_ModuleB use that attribute to do some.

EDIT: I almost forget... if you don't have any specific data or code dependency but you just need that My_ModuleA comes before MyModuleB ie: because both are observing the same event, you could use dependency to such order related tasks too.

Based on the examples below you should declare:

app/etc/modules/My_ModuleA.xml

<config>
    <modules>
        <My_ModuleA>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Core/>
                <Mage_Eav/>
                <Mage_Catalog/>
            </depends>
        </My_ModuleA>
    </modules>
</config>

app/etc/modules/Your_ModuleA.xml

<config>
    <modules>
        <Your_ModuleA>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <My_ModuleA/>
            </depends>
        </Your_ModuleA>
    </modules>
</config>

app/etc/modules/My_ModuleB.xml

<config>
    <modules>
        <My_ModuleB>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <My_ModuleA/>
            </depends>
        </My_ModuleB>
    </modules>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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