gpt4 book ai didi

magento - Magento 如何使用模块配置文件中的 module_name 标签元素

转载 作者:行者123 更新时间:2023-12-02 10:47:35 25 4
gpt4 key购买 nike

我找到了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

每个模块都会根据需要读取其配置,并且没有正式的定义。这种灵 active 允许任何模块为任何其他模块的设置做出贡献。

关于magento - Magento 如何使用模块配置文件中的 module_name 标签元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5207698/

25 4 0