Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Examining Magento's final XML structure

Tags:

magento

Anyway to examine the final XML structure magento comes up with after parsing & combining all the different XML files?

  1. There is nothing of that sort which turned up on searching on the internet and I think for someone like me, magento layouts were a bit too much in the beginning & I would try to do everything on the code side.
  2. Another thing which will help in picking up the name of different nodes that we can use, right away from the final XML structure.
  3. Never ran into this but I believe we will have a better picture of what's overriding what.
like image 773
Ashfame Avatar asked Dec 03 '12 16:12

Ashfame


3 Answers

The following will get you the merged configuration from app/etc/*.xml, app/etc/modules/*.xml, as well as each (active) module's config.xml file; when retrieving the config though there is no indication of what was overwritten, as the merges happen as each config file is being parsed:

Mage::getConfig()->getNode()->asNiceXml(); // or asXML() | asArray() | etc.

However, you seem to be asking about how the application makes use of this information. This is a function of application design.

Also, you mention "all of the different XML files." It's worth noting that these are not maintained in one massive object instance. For example, layout XML is accessed using the layout update object Mage_Core_Model_Layout_Update and can be accessed meaningfully after it's been loaded and manipulated for a given rendering scope (e.g. loadLayout() in a controller action):

Mage::app()->getLayout()->getUpdate()->asString(); // or asSimplexml() or asArray()
like image 168
benmarks Avatar answered Nov 15 '22 09:11

benmarks


Yes - Commercebug. As well as a whole load of other useful features, you can also view the entire XML structure that Magento has produced.

http://store.pulsestorm.net/products/commerce-bug-2

like image 26
McNab Avatar answered Nov 15 '22 09:11

McNab


I believe the following will output the XML: echo Mage::getConfig()->getXmlString();

You can create a script with something like this:

header("Content-Type:text/xml");

require_once '../app/Mage.php';

Mage::app();

echo Mage::getConfig()->getXmlString();
like image 36
jmspldnl Avatar answered Nov 15 '22 10:11

jmspldnl