在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这个服务告诉我们正确的答案是“store/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)或
$data = $config->getNode('default/' . $path);
(default/some/value)如果我们调试它,我们可以看到,store只有admin和storenames子节点。有人能澄清这一点吗?我错过什么了吗?
发布于 2015-02-24 22:36:21
你是对的,Elance考试是错的。
可能的Xpath包括:
default/some/value (默认configuration)stores/[store]/some/value (存储configuration)https://stackoverflow.com/questions/28698208
复制相似问题