11

I want to modify 3rd party extension and want to override its functionality with the new extension. But my main concern is what if 3rd party extension is not enabled or present in my Magento folder? I want to set dependancy using ifconfig in system.xml or config.xml but I am not sure at extension level that how to check if extension is present in folder. TIA.

EDIT : Thanks to @Sander Mangel for dependency answer. Now let me be more clear.

I can easily set dependency using app/etc/modules/MyNameSpace_MyModule.xml but when my 3rd party extension is removed from system, error report is generated and its showing "Module "MyNameSpace_MyModule" requires module "3rdPartyExtension" and stopped further execution cause it has generated exception but what if I want to execute further without generating exception? Simply MyExtension will not take effect if 3rdpartyextension is not present without stopping magento to execute. So that's why I am asking is there any kind of facility like we did on layout files to check. NOTE ifconfig here.

<reference name="sales.order.print">
        <action method="setTemplate" ifconfig="3rdparty/config">
            <template>mytemplate.phtml</template>
        </action>
    </reference>

Second Edit : Thanks to Zyava. I did what I want but say If I deleted my 3rd party extension for trial purpose to see what happens.. I created my system.xml as below

<config>
   <sections>        
        <payment>
            <groups>
                <3rdparty extension translate="label" module="payment">
                    <label>3rd Party</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>1</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>                                                
                        <disallowedcustomergroups translate="label comment">
                            <label>Disallowed Customer Groups</label>
                            <frontend_type>multiselect</frontend_type>
                            <sort_order>120</sort_order>
                            <source_model>adminhtml/system_config_source_customer_group</source_model>
                            <config_path>mymodule/disallowed_customer_groups</config_path>
                            <comment><![CDATA[Press control and select multiple groups]]></comment>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <depends><active>1</active></depends>
                        </disallowedcustomergroups>                        
                    </fields>
                </3rdpartyextension>
            </groups>
        </payment>        
    </sections>
</config>

So you can see that I have simply specified one tab based on activation of 3rd party extension. But I have deleted 3rd party extension fully from my system but still its showing other options of 3rd party extensions? Why its showing them though I have cleared my cache?

13

As far as I understand what you need, you should use <depends tag, example from app/code/core/Mage/Paypal/etc/system.xml:

<payment_action translate="label">
    <label>Payment Action</label>
    <config_path>payment/paypal_express/payment_action</config_path>
    <frontend_type>select</frontend_type>
    <source_model>paypal/system_config_source_paymentActions_express</source_model>
    <sort_order>30</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <shared>1</shared>
</payment_action>

<authorization_honor_period translate="label comment">
    <label>Authorization Honor Period (days)</label>
    <comment>Specifies what the Authorization Honor Period is on the merchant’s PayPal account. It must mirror the setting in PayPal.</comment>
    <config_path>payment/paypal_express/authorization_honor_period</config_path>
    <frontend_type>text</frontend_type>
    <sort_order>50</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <shared>1</shared>
    <depends><payment_action>Order</payment_action></depends> <!-- see this line -->
</authorization_honor_period>
  • Thank you so much... I can find that in core xml but don't know exactly what it does. – Kamal Apr 12 '13 at 10:02
  • Please refer my second edit... – Kamal Apr 12 '13 at 10:07
  • If in payment_action field you select Order, field authorization_honor_period becomes visible. – Dmytro Zavalkin Apr 12 '13 at 17:21
1

Dependencies can be set in your app/etc/modules XML. Magento will check if the extension is available.

<?xml version="1.0"?>
<config>
    <modules>
        <Your_Extension>
            <active>true</active>
            <codePool>community</codePool>
            <depends>
                <3thparty_Extension/>
            </depends>
        </Your_Extension>
    </modules>
</config>

Or use the following code to check if an extension is enabled. This can be done by creating a helper method in Namespace/Module/Helper/Data.php

class Namespace_Module_Helper_Data extends Mage_Core_Helper_Abstract 
{

   public function extensionEnabled()
   {
      return Mage::getStoreConfig('advanced/modules_disable_output/Namespace_Module');
   }
}
  • Thanks for your answer.. What if I have to check extension is enabled or not? – Kamal Apr 12 '13 at 7:51
  • Hey Kamal, you could use Mage::getStoreConfig('advanced/modules_disable_output/Namespace_Module');. I've added the code in my awnser – Sander Mangel Apr 12 '13 at 7:53
  • yeah that's true but what if I wish to check in system.xml like normally we can check in layout.xml of theme using ifconfig? – Kamal Apr 12 '13 at 7:56
  • So only adding your config fields if the 3th party tab in system > configuration is present? – Sander Mangel Apr 12 '13 at 7:58
  • No actaully want to provide further options based on selection.. – Kamal Apr 12 '13 at 8:00

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.