How to debug errors in Prestashop
Debugging can be a daunting task, because with so many versions of prestashop modules, third and different hosting platforms, can be an arduous task. This tutorial is to verify that our store does not contain errors, and if I had, try to fix or determine the problem to seek help in
- The first step in debugging is enable debugging it brings prestashop. This will show us in the front office errors that could have our store. To enable debugging, we edit the file config/config.inc.php and put in on the display_errors and the PS_DEBUG_SQL true (for errors in database queries), leaving the file as shown below:
ini_set ('display_errors', 'on');
define ('_PS_DEBUG_SQL_', true);
In ps 1.5/1.6, the file is config/defines.inc.php and set PS_DEV_MODE to true
We also have a free module that lets you change these parameters from the back office:
- Debugging enabled, we must visit our site from the front office for possible error messages. It is ideal to browse all sections, my own products, contact, etc.. If you have something not work, we address only whether section where we know that is the problem to see the error. The errors that we find are many. We will see some common.
- Problems with Smarty - smarty engine is the one used to templatesprestashop. As prestashop is changing and updated version, it is normal that the templates must also do so and include new code and variables. In many cases a template created for prestashop 1.4.3 does not work well in PS PS 1.4.1 or 184.108.40.206 for example. This will only know what debugging and activating the template traveling for errors. A typical case of error is as follows:
In the error message, we can see that it is in the file themes/Perfume/address.tpl, and refers to a variable not recognized. More likely is that the file does not correspond with address.tpl version of prestashop we have installed. To resolve this, we can replace that file with the file default prestashop template and see if the error is corrected. It is worth mentioning that if the file
has been customized, such customization and we lose to do it again.
- Many times when modifying CSS files or TPL, we see no changes. This is because security is enabled cache. To force to rewrite the cache after editing TPL files and CSS, we go to preferences/performance or advanced parameters/performance and force the compilation and disable the cache:
We also have a free module that cleans the smarty cache without having to modify these options. The module is the clear smarty in all ps versions:
You can also delete files manually via ftp from tools/smarty/compile or tolos/smarty_v2/compile (Do not delete the index.php) or cache/smarty/compile.
- Many times you will not see any error messages, just a blank page. In this case, we can go to the menu of your browser and find the option to View Source. Since the source code we find the error. Will surely be of some module, and that fails to compile all the template and therefore do not see the front office.
At the end of file we can see where the problem:
Prestabook.tpl file belongs to a module, which probably is not compatible with our version. In these cases it is best to look to the creator module to give us a version for our store and off the module to avoid errors.
- Many times we have problems in the store, but the debug shows us no prestashop error. In these cases the errors may come from java scripts/jquery conflicting with some code in our store. To verify this, use google chrome (you can do in firefox with firebug also or any other browser). We go to our site and activate the debug view (right click,inspect element):
And then we click the Show button console:
If no errors appear to us, we're good. We will have to inspect the entire site and take action to add products to cart, change management and user data, perform a test order, and so on. For example, here we show an error:
Uncaught ReferenceError: mclosetime is not defined At the end of the line, we see that file is the error "product.php:238", clicking that file will show us exactly where the error:
As we can see, is related to the block of languages, probably with a custom code:
This is because many templates modified modules and can bring conflict with prestashop default code. We should see if we have a folder named template modules, and within a folder with the name of the module that causes the problem. We can rename the folder to load the module prestashop original and see if the problem is solved.
This must also be taken into account if we modify a module and we see no change, because if the template has custom modules within our theme/modules, we need to modify those files, not the originals that are in prestashop/modules.
- Another common point of error is the memory limit on some servers. This can cause errors of many kinds, but the most common is that we do not show all modules, or memory have a message like this:
The solution to this problem is to increase the amount of available memory. With the Debug module can do it from the back office
And put the memory on a 256MB value. It all depends on the number of modules we use.
We can also add a line in the config / config.inc.php with the memory value ini_set ('memory_limit', '256M ');
We must prove to a high value, and enter the following numbers (8, 16, 32, 64, 128.256, etc..) The M is megabytes.
If this fails, we must contact our host to modify these values for us.
- In Prestashop new versions and some hosts, you have a error_log file, in the root site or in subfolders, that contains erros like missing variables, libraries, etc. you can download and check open with any text editor to find the errors.