How to log all xml layout updates in Magento on each request


/ Published in: PHP
Save to your folder(s)

Snippet for logging down all of the layout updates loaded on each request in Magento.


Copy this code and paste it in your HTML
  1. //Full path to the log file:
  2. $logPath = Mage::getConfig()->getOptions()->getVarDir().DS.$file_name.time().'.xml';
  3.  
  4. //Layout model: Mage_Core_Model_Layout
  5. $layout = Mage::getSingleton('core/layout');
  6.  
  7. //Generate our xml with Mage_Core_Layout_Update model and save it in a file
  8. $xml = '<'.'?xml version="1.0"?'.'>';
  9. $xml .= '<layout>'.trim($layout->getUpdate()->asString()).'</layout>';
  10. file_put_contents($logPath, $xml);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.