Magento getStoreConfig任务。在elance.com上

Magento getStoreConfig任务。在elance.com上,magento,Magento,elance.com上有一个关于getStoreConfig函数的问题。认证考试中很可能存在这样的问题 Which one of the following xpaths can be read using Mage::getStoreConfig('some/value')? Answers: • default/some/value • some/value • some/value/default • global/default/some/value • stores/some/va

elance.com上有一个关于getStoreConfig函数的问题。认证考试中很可能存在这样的问题

Which one of the following xpaths can be read using Mage::getStoreConfig('some/value')?

Answers:

• default/some/value
• some/value
• some/value/default
• global/default/some/value
• stores/some/value
这项服务告诉我们正确的答案是“存储/部分/值”。但如果我们研究代码,我们将看到:

public static function getStoreConfig($path, $store = null)
{
    return self::app()->getStore($store)->getConfig($path);
}

public function getConfig($path)
{
    if (isset($this->_configCache[$path])) {
        return $this->_configCache[$path];
    }

    $config = Mage::getConfig();

    $fullPath = 'stores/' . $this->getCode() . '/' . $path;
    $data = $config->getNode($fullPath);
    if (!$data && !Mage::isInstalled()) {
        $data = $config->getNode('default/' . $path);
    }
    if (!$data) {
        return null;
    }
    return $this->_processConfigValue($fullPath, $path, $data);
} 
这意味着正确的答案是:

$fullPath = 'stores/' . $this->getCode() . '/' . $path;
(stores/default{or some another store}/some/value)


如果我们调试这个,我们可以看到,stores只有admin和storenames子节点。有人能澄清一下吗?我错过什么了吗?

你是对的,而Elance考试是错的

可能的XPath有:

  • default/some/value
    (默认配置)
  • stores/[store]/some/value
    (存储配置)
$data = $config->getNode('default/' . $path);
(default/some/value)