How do I know whether my Config.xml file is workin

2020-03-07 17:33发布

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?

4条回答
Lonely孤独者°
2楼-- · 2020-03-07 17:59

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楼-- · 2020-03-07 18:03

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楼-- · 2020-03-07 18:04

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.

查看更多
Rolldiameter
5楼-- · 2020-03-07 18:13

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.

查看更多
登录 后发表回答