I think you want to enable Developer mode. Add this to your .htaccess file:
Code:
SetEnv MAGE_IS_DEVELOPER_MODE "true"
You may also want to enable display errors in index.php:
PHP Code:
ini_set('display_errors', 1);
The best way I have found to debug is with X-Debug in a local environment. You can also use log files to help debug in a production environment, if your unable to run X-Debug in the environment.
I've got a more detailed posting here:
http://www.molotovbliss.com/debuggin...gento-commerce
Consider also installing XDebug
Or in another way with printDebugBacktrace. printDebugBacktrace function looks like:
PHP Code:
public static function printDebugBacktrace($title = 'Debug Backtrace:') {
$output = "";
$output .= "<hr /><div>" . $title . '<br /><table border="1" cellpadding="2" cellspacing="2">';
$stacks = debug_backtrace();
$output .= "<thead><tr><th><strong>File</strong></th><th><strong>Line</strong></th><th><strong>Function</strong></th>".
"</tr></thead>";
foreach($stacks as $_stack)
{
if (!isset($_stack['file'])) $_stack['file'] = '[PHP Kernel]';
if (!isset($_stack['line'])) $_stack['line'] = '';
$output .= "<tr><td>{$_stack["file"]}</td><td>{$_stack["line"]}</td>".
"<td>{$_stack["function"]}</td></tr>";
}
$output .= "</table></div><hr /></p>";
return $output;
}
You need to put the above method in app/Mage.php.
Note: As you see that above method utilizes the php’s debug_backtrace() method. But manually calling that function will give you very large string due to large no of complex properties & nested objects in magento classes and will be very difficult in tracing. So recommended to use the above mentioned utility function instead.
Usage
Suppose say you are trying to figure out the flow of Mage_Sales_Model_Quote_Address_Total_Shipping::col lect() method.
Go to that class method and put the following line
PHP Code:
public function collect(Mage_Sales_Model_Quote_Address $address)
{
echo Mage::printDebugBacktrace(); exit; //add this line just after the opening
//Mage::log(Mage::printDebugBacktrace(), null, 'backtrace.log'); //or you can even log the backtrace
And when you load the page (my cart) in frontend then you will get the following output:
Good luck with your debug
Bookmarks