Pretty Debug Output
Yeh it's not Magento, but this might help some people:
Zend_Debug::dump()
Basically it's var_dump but with <pre>
tags, no biggie but it's nice to use.
Related cards:
Enabling MySQL Query Logging
In /lib/Varien/Db/Adapter/Pdo/Mysql.php change this property to true:
/**
* Write SQL debug data to file
*
* @var bool
*/
protected $_debug = false;
To enable logging for queries slower than a certain ti...
Pretty Backtrace / Stack Trace
In app/code/core/Mage/Core/functions.php
Magento offers a function named mageDebugBacktrace()
which is nice, but I thought could be made nicer. This backtrace shows frame numbers, file names and line numbers, classes, methods and arguments whe...
Get Methods of Class
Yes, very dirty, but it works a treat! Save this file in your Magento root directory, then fire up a command line and run whatever.php Mage_Core_Model_App
(or some other class) and you should see the output.
Output looks like below:
$ ./cl...
Enabling The Profiler
In index.php uncomment this line:
#Varien_Profiler::enable();
In the admin enable the profiler output:
Set System
> Configuration
> Advanced
> Developer
> Debug
> Profiler
to yes
To enable the Zend_Db profiler add the followin...
Cache Clearing And General Information
Clean everything (use either):
Mage::app()->getCacheInstance()->flush();
Mage::app()->getCache()->clean();
Clean specific types:
Mage::app()->getCacheInstance()->cleanType('config');
Mage::app()->getCacheInstance()->cleanType('l...
Restoring console.log
To do this permanently by altering your JS files, comment out this code on line 637 of js/varien/js/js
:
if (!("console" in window) || !("firebug" in console))
{
var names = ["log", "debug", "info", "warn", "error", "assert", "di...
Collection Manipulation (Filtering, Limiting, etc)
A list of collection methods, similar to this
Where
OR:
You have to first specify an array of attributes in the filter, then a two dimensi...
Resizing A Product Image
$helper = Mage::helper('catalog/image');
$helper->init($product, 'image');
$helper->resize(216, 161);
// the helpers __toString() method outputs the url
echo $helper;
![](http://mikewhitby.co.uk/makandra-track.gif?a=resizing-...
Paypal Express Flow
The PayPal Express Checkout Integration Guide is a great
source of well-written information for anything relating to the Express
checkout, including information regarding all of the API calls. Also, the PayPal
Express Checko...
Fetching All Attributes For An Entity From The DB In One Query
Using the database to inspect EAV-based entity types can be a real pain in the ass, so here are a bunch of queries that let you inspect some popular EAV entity types easily. This practice can be applied to any EAV entity type, however as there are...