Prestashop

How to enable reporting Error Reporting on Prestashop 1.6.x/1.5.x

Blank page error? (very common) Modules not working? Whatever strange behavior on your website? Enabling Error Reporting is the first step in order to be able to investigate and possibly solve the issue.

First step, enable Debug Mode by opening config\defines.inc.php file locate and change this line:

define('_PS_MODE_DEV_', false);

into this one:

define('_PS_MODE_DEV_', true);

This should be enough for you to be able to see errors, but there is one more thing you can do, dump all erors in a csv file: to do that just copy paste the following code at the beginning of your index.php file

<?php error_reporting(0); 
$old_error_handler = set_error_handler("userErrorHandler");
 
function userErrorHandler ($errno, $errmsg, $filename, $linenum,  $vars) 
{
$time=date("d M Y H:i:s"); 
// Get the error type from the error number 
$errortype = array (1    => "Error",
2    => "Warning",
4    => "Parsing Error",
8    => "Notice",
16   => "Core Error",
32   => "Core Warning",
64   => "Compile Error",
128  => "Compile Warning",
256  => "User Error",
512  => "User Warning",
1024 => "User Notice");
$errlevel=$errortype[$errno];
 
//Write error to log file (CSV format) 
$errfile=fopen("errors.csv","a"); 
fputs($errfile,"\"$time\",\"$filename: 
$linenum\",\"($errlevel) $errmsg\"\r\n"); 
fclose($errfile);
 
if($errno!=2 && $errno!=8) {
//Terminate script if fatal error
die("A fatal error has occurred. Script execution has been aborted");
} 
}
?>

You will now have all errors logged in the errors.csv file that you can find in the htdocs or www root of your website.