我发现here Magento 使用这些标签作为自定义配置变量,但我仍然无法理解它们在哪里使用以及如何使用。 例如,Wishlist 模块在其定义的 config.xml 文件中具有 wishlist(与模块同名)xml 标签:
<item>
<product_attributes>
<visibility/>
<url_path/>
<url_key/>
</product_attributes>
</item>
该模块在哪里使用这些配置? 另外,如果我要构建付款方式,我必须在自定义模块 config.xml 中添加 sales 的标签,然后添加 quote 的标签,依此类推... 我还发现了其他相关问题,但大多数答案是这些标签可以是任何东西,但我需要知道系统如何使用它们。 先谢谢你了
在这种情况下,直接负责的文件是
app/code/core/Mage/Wishlist/Model/Config.php
,其中完全由以下内容组成:
class Mage_Wishlist_Model_Config
{
const XML_PATH_PRODUCT_ATTRIBUTES = 'global/wishlist/item/product_attributes';
/**
* Get product attributes that need in wishlist
*
*/
public function getProductAttributes()
{
$attrsForCatalog = Mage::getSingleton('catalog/config')->getProductAttributes();
$attrsForWishlist = Mage::getConfig()->getNode(self::XML_PATH_PRODUCT_ATTRIBUTES)->asArray();
return array_merge($attrsForCatalog, array_keys($attrsForWishlist));
}
}
因此,每当您需要专门读取配置时,只需使用
Mage::getConfig()->getNode()
并传递您感兴趣的节点的路径。在本例中,路径是 global/wishlist/item/product_attributes
,您已经知道了。
每个模块都会根据需要读取其配置,并且没有正式的定义。这种灵活性允许任何模块为任何其他模块的设置做出贡献。