How Magento uses module_name tag elements in a module configuration file

I found here that Magento uses these tags as custom configuration variables, but I still cannot figure out where they are used and how. For example, the Wishlist module has a wish list (the same name as the module) of the xml tag in the config.xml file in which it defines:

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

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

+4
source share
1 answer

In this case, the directly responsible file is app/code/core/Mage/Wishlist/Model/Config.php , where it 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 configuration, just use Mage::getConfig()->getNode() and go through the path to the node that interests you. In this example, the path global/wishlist/item/product_attributes , which you already know.

Each module will read the configuration as necessary and there is no formal definition. This flexibility allows any module to contribute to any other module settings.

+3
source

Source: https://habr.com/ru/post/1342464/


All Articles