How do I know whether my Config.xml file is working in Magento?

守給你的承諾、 提交于 2019-12-19 05:08:06

问题


I have created a sample module, but I am not sure if its /module/etc/config.xml file is getting loaded. I am sure there is a problem in that only. Is there a way that I can find out whether this file is getting loaded?


回答1:


If you have a good debugger Xdebug or Zend Debugger, you can check the variable $mergeToObject in the method loadModulesConfiguration of the class Mage_Core_Model_Config.

Or the bad guy way :-), you die the script at the same place but just before return $mergeToObject; you do print_r($mergeToObject);.

You could see in this method if your module is loaded too.

A debugger is your best friend. ;-)

All of this allow to check what is loaded from your config.xml but doesn't mean that the syntax is correct into your config.xml to load models or else. You should take a look in other config.xml of the core modules to help you.

I have forgotten, check if you module is correctly loaded and recognized by Magento after a cache flush, you should take a look in the System > configuration > advanced tab and see if your module name appears.




回答2:


The free Module List module (built by me) will tell you which module's are installed in the system, and will tell you if your config.xml is being loaded.




回答3:


Drop this in the bottom of your index.php, similar to Alans Module List but a quick code copy/paste approach. Remember all of Magento's XML's get combined into one XML tree.

header("Content-Type: text/xml");
die(Mage::app()->getConfig()->getNode()->asXML());



回答4:


As long as you have Your_Module.xml in app/etc/modules/ and it is enabled (might have to flush the cache if you have caching enabled), app/code//Your/Module/etc/config.xml is one of the most sure things that will load. Other files may not for different reasons, but that one will always load. Whether or not it's properly set up to let your module work is an entirely different story though. I've spent plenty of time debugging a config.xml file to find some minor spelling error was the reason my module wasn't working.

Alternatively, you could throw some invalid XML into it and see if Magento borks out.



来源:https://stackoverflow.com/questions/7835275/how-do-i-know-whether-my-config-xml-file-is-working-in-magento

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!