你打电话时
$this->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE)
它会打电话
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);
}
也
protected function _processConfigValue($fullPath, $path, $node)
{
if (isset($this->_configCache[$path])) {
return $this->_configCache[$path];
}
if ($node->hasChildren()) {
$aValue = array();
foreach ($node->children() as $k => $v) {
$aValue[$k] = $this->_processConfigValue($fullPath . '/' . $k, $path . '/' . $k, $v);
}
$this->_configCache[$path] = $aValue;
return $aValue;
}
$sValue = (string) $node;
if (!empty($node['backend_model']) && !empty($sValue)) {
$backend = Mage::getModel((string) $node['backend_model']);
$backend->setPath($path)->setValue($sValue)->afterLoad();
$sValue = $backend->getValue();
}
if (is_string($sValue) && strpos($sValue, '{{') !== false) {
if (strpos($sValue, '{{unsecure_base_url}}') !== false) {
$unsecureBaseUrl = $this->getConfig(self::XML_PATH_UNSECURE_BASE_URL);
$sValue = str_replace('{{unsecure_base_url}}', $unsecureBaseUrl, $sValue);
} elseif (strpos($sValue, '{{secure_base_url}}') !== false) {
$secureBaseUrl = $this->getConfig(self::XML_PATH_SECURE_BASE_URL);
$sValue = str_replace('{{secure_base_url}}', $secureBaseUrl, $sValue);
} elseif (strpos($sValue, '{{base_url}}') !== false) {
$sValue = Mage::getConfig()->substDistroServerVars($sValue);
}
}
$this->_configCache[$path] = $sValue;
return $sValue;
}
当你打电话时
Mage::getConfig()->getNode(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE)
它将读取xml
文件并返回输出。
我认为按照@Marius先生的建议,它不会影响性能。