Search code examples
phpmagentoconfig

How is Magento using the module_name tag elements in the module config file


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


Solution

  • 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.