Magento doesn't seem to like me setting blank config values at website or store level.

Steps to reproduce (,,

1) change config scope to website
2) untick use default next to 'default welcome message'
3) clear the text in the field
4) save

At this stage Magento will re-tick the use default box, however, it has saved my blank value. The next time I save this config page the config value from the default level is used.

This functionality was not present in 1.4, and I don't have 1.5 to test.

My question is, how do I create blank config values at the website or store level?


In version 1.7.02 the code looks like this:

            $path = (string)$element->config_path;
            if (empty($path)) {
                $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $element->getName();
            } elseif (strrpos($path, '/') > 0) {
                // Extend config data with new section group
                $groupPath = substr($path, 0, strrpos($path, '/'));
                if (!isset($configDataAdditionalGroups[$groupPath])) {
                    $this->_configData = $this->_configDataObject->extendConfig(
                    $configDataAdditionalGroups[$groupPath] = true;

And it uses empty() to evaluate the string.

Does anyone have a suggestion to modify this code to allow empty strings that I specify to override the default?

1 Answer 1


The problem comes from here:

[For Magento]
Around line 295 there is this piece of code:

if (isset($this->_configData[$path])) {
    $data = $this->_configData[$path];
    $inherit = false;
} else {
    $data = $this->_configRoot->descend($path);
    $inherit = true;

This determines if the 'Use website/Use default value' checkbox is checked or not. The problem is that when a value is empty $this->_configData[$path] is null. And the function isset() returns true only if the parameter exists and is not null.
If you replace
if (isset($this->_configData[$path])) {
if (array_key_exists($path, $this->_configData)) {
it should work.

[For Magento]
In version the code from above was moved in Mage_Adminhtml_Model_Config_Data::getConfigDataValue()

It's a similar piece of code and the solution is the same:
At line 388 there is this:

if (isset($configData[$path])) {

that should be replaced by this:

if (array_key_exists($path, $configData)) {
  • +1 for being in the right direction, which version does your code example come from? is different. See updated question Commented Apr 4, 2013 at 10:42
  • i checked for but there is no difference in Below the code you posted in the question is the code I posted in the answer. Changing what I suggested should fix the problem, but try not to do it in the core file directly. Copy it in the local folder or extend the class.
    – Marius
    Commented Apr 4, 2013 at 10:56
  • Im not a noob, but your code is not in my file! I must not have the version I think I do. Commented Apr 4, 2013 at 23:19
  • well ...damn. It IS different for My bad. I updated the answer with instructions on what to do for v1.7.0.2
    – Marius
    Commented Apr 5, 2013 at 7:10

Your Answer

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

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