Ashfame
Ashfame

Reputation: 1769

Examining Magento's final XML structure

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.

Upvotes: 6

Views: 1407

Answers (4)

PVL
PVL

Reputation: 121

based on answer from benmarks I did

echo "<pre>".htmlspecialchars(Mage::getConfig()->getNode()->asNiceXml())."</pre>";

If you want for example to see the blocks configuration in Magento 1 you can put this in a file, place the file at the root of the site and navigate to it in a browser:

<?php
include("app/Mage.php");
Mage::app(); 

//just see blocks...
echo "<pre>".htmlspecialchars(Mage::getConfig()->getNode()->global->blocks->asNiceXml())."</pre>";
die();

Upvotes: 0

benmarks
benmarks

Reputation: 23205

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()

Upvotes: 8

jmspldnl
jmspldnl

Reputation: 176

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();

Upvotes: 1

McNab
McNab

Reputation: 6777

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

Upvotes: 2

Related Questions