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

Could someone help me with the following issue I have with a module. I've been stuck for a couple of hours and could do with a fresh perspective.

I have two modules ModuleA and ModuleB which both extend the same Onepage_Checkout class using rewrites. I've almost solved the issue of the rewrite but I have ran into two issues.

The first is that ModuleA and ModuleB both add a step to Onepage Checkout. Each additional step is visible but for some reason ModuleB is skipped and doesn't become active.

The second is I need to add an option to disable or enable ModuleA per store/website

I've added this code to the system.xml file but it doesn't seem to work

<enable translate="label">
          <label>Enable</label>
          <frontend_type>select</frontend_type>
          <source_model>adminhtml/system_config_source_yesno</source_model>
          <sort_order>10</sort_order>
          <show_in_default>1</show_in_default>
          <show_in_website>1</show_in_website>
          <show_in_store>1</show_in_store>
        </enable> 

Do I need to alter the DB table in anyway or is there something else that I have missed?

Also, if I disable ModuleB for StoreA and disable ModuleA for storeB due to dependancies will they both still be active in either store? The reason I ask is I need to have the flexibilty to enable or disable each module per store and not have them both active...

Can anyone assist? Really appreciate it...

share|improve this question

1 Answer

There is no connection between any config setting and your module unless you evaluate that setting in PHP.

Once upon a time there were two extensions which everyone installed on their Magento site: Fooman_Speedster and Yoast_CanonicalUrl. Both rewrote the Mage_Page_Block_Html_Head class, so both authors had instructions on how to handle this. Because Yoast's extension loaded after Fooman's (Y > F), Yoast came up with a workaround which helped most people who were installing the extensions via Connect and had no ability to work with the code.

In Yoast/CanonicalUrl/Block/Head:

if (!(string)Mage::getConfig()->getModuleConfig('Fooman_Speedster')->active == 'true')
{
  class Fooman_Speedster_Block_Page_Html_Head extends Mage_Page_Block_Html_Head{}
}
  class Yoast_CanonicalUrl_Block_Head extends Fooman_Speedster_Block_Page_Html_Head
{
     //Yoast's class definition...
}

This suggests an approach for you. You will need to read store-relative values though

Mage::getStoreConfig('[section]/[group]/enable')

and handle condition combinations where the other module is active or not.

share|improve this answer
Ahh I see I will have a go. Thanks! – user2157 May 21 at 13:45
Thanks for posting that, preemptive extension of a module you might have load beside yours, something I've been needing. And if you decide to remove the other module, it reverts... Which I was looking for. – Fiasco Labs May 21 at 14:08
1  
The good old days before you could use Mage::helper('core')->isModuleEnabled('Fooman_Speedster') to check for an active module – Fooman May 21 at 14:15

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.