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

发布于 2024-10-20 05:55:56 字数 632 浏览 2 评论 0原文

我发现这里 Magento正在使用这些标签作为自定义配置变量,但我仍然不明白它们在哪里使用以及如何使用。 例如,Wishlist 模块在 config.xml 文件中具有 wishlist (与模块同名)xml 标记,其中定义:

<item>
    <product_attributes>
        <visibility/>
        <url_path/>
        <url_key/>
    </product_attributes>
</item>

该模块在哪里使用这些配置? 另外,如果我要构建付款方式,我必须在自定义模块 config.xml 中添加 sales 标签,然后添加 quote 标签,依此类推... 我还发现了其他相关问题,但大多数答案是这些标签可以是任何东西,但我需要知道系统如何使用它们。 先感谢您

I found here that Magento is using these tags as custom config variables, but I still cannot understand where are they used and how.
For example the Wishlist module has wishlist (same name as the module) xml tag in the config.xml file in which it defines:

<item>
    <product_attributes>
        <visibility/>
        <url_path/>
        <url_key/>
    </product_attributes>
</item>

Where is this module using these configurations?
Also if I was to build payment method, I have to add in my custom module config.xml a tag for sales and then for quote and so on...
I also found other related questions, but most of the answers were that these tags can be anything, but I need to know how they are used by the system.
Thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白龙吟 2024-10-27 05:55:56

在这种情况下,直接负责的文件是 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

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

In this case the file directly responsible is app/code/core/Mage/Wishlist/Model/Config.php where consists entirely of this:

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));
    }
}

So whenever you need to read the config specifically just use Mage::getConfig()->getNode() and pass the path of the node that interests you. In this example the path is global/wishlist/item/product_attributes, which you already know.

Each module will read it's configuration as it needs and there is no formal definition. This flexibility allows any module to contribute to any other module's settings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文