1

I am trying to read config data for a custom module to enable or disable it based on the config setting. I am trying to read the config data in an Observer like this : $module_state = Mage::helper('stopcheckout')->moduleActive(); and here is my helper. My observer gets called when ever a product is added to cart. But i get a blank page when i try to read the config data with the above snipped of code. Here are the config.xml and system.xml files. Where am i going wrong? Thanks.

1 Answer 1

10

Your helper method is not correct, as I'm sure you've guessed :-)

Try this:

<?php
class Foostor_Stopcheckout_Helper_Data extends Mage_Core_Helper_Abstract
{
    /**
     * Check if the extension has been disabled in the system configuration
     */
    public function moduleActive()
    {
        return ! (bool) Mage::getStoreConfigFlag('catalog/stopcheckout/disable_ext');
    }
}

The getStoreConfigFlag() method always returns a boolean. It evaluates the strings "false" and "0" as false, so this is appropriate because the adminhtml/system_config_source_yesno source model uses 1 and 0 as the stored values.

The parameter that is passed for values set via system.xml fields will always have three parts: one for the <sections> node, one for the <groups> node, and one for the <fields> node.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.