Skip to content

Instantly share code, notes, and snippets.

@oliverde8
Last active May 27, 2019 12:31
Show Gist options
  • Save oliverde8/f121ea479bb3efa8683783c357c2bdfc to your computer and use it in GitHub Desktop.
Save oliverde8/f121ea479bb3efa8683783c357c2bdfc to your computer and use it in GitHub Desktop.
Magento 1 - Add comment blocks to html output to debug layout & blocks.
<?php
/**
* Modify
* File : app/code/core/Mage/Core/Block/Template.php
* Method: fetchView
* At the very begining.
*
*/
$startTime = microtime(true);
/**
* Modify
* File : app/code/core/Mage/Core/Block/Template.php
* Method: fetchView
* At the end replace the return.
*
*/
$block = get_class($this);
$tags = implode(',', $this->getCacheTags());
$key = $this->getCacheKey();
$time = date(DATE_ISO8601);
$genTime = microtime(true) - $startTime;
$debug = "<!-- ";
$debug .= "\n\t- Block: $block";
$debug .= "\n\t- name: {$this->getNameInLayout()}";
$debug .= "\n\t- template: $includeFilePath";
$debug .= "\n\t- date: $time";
$debug .= "\n\t- cache-key: $key";
$debug .= "\n\t- cache-lifetime: " . $this->getCacheLifetime();
$debug .= "\n\t- cache-tags: $tags";
$debug .= "\n\t- cache-ttl: {$this->getCacheLifetime()}";
$debug .= "\n\t- gen-time: $genTime";
$debug .= "-->";
return $debug . $html;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment