Debugging is an art. Knowing the principles of debugging can be key to ruling out the cause of issues you are facing. Debugging is a set of the processes that help us locate and resolve bugs/errors or abnormalities in computer programs. Each process runs methodically via a debugging tool or manually monitored by a tester/debugger.
If you are new to the Magento platform, you have to digest a vast amount of code which can be quite overwhelming. However, I am sharing some tips with you today that I have learned over the years of dissecting Magento. These Magento debugging tips can be applied to most Magento bugs/errors. It is recommended that you follow each and every point mentioned below until you reach a solution.
Here are the methods you can use to debug your Magento store:
- Enable Magento Logging
- Clear the Magento Cache
- Reindex Magento Indexers
- Disable Magento Compilation
- Enable PHP Display Errors
- Enable Magento Developer Mode
- Reset Permissions
- Change Magento Theme to Default
- Disable Local Modules
- Enable Magento Profiler
Enable Magento Logging
Magento logs a lot of stuff in exception.log and system.log files. Before anything, exception and system logs need to be activated from the Magento admin panel. Navigate to the System > Configuration > Developer > Log and set Enabled to Yes.
Clear the Magento Cache
If you are using any caching tool within Magento, clearing cache can help you find answers to the problem you are facing.
There are two ways to clear the Magento cache. First, go to System > Cache Management and tap the “Flush Cache Storage” button. Second, delete the “Cache” folder under MAGENTO_ROOT/var directory.
Reindex Magento Indexers
Magento uses an EAV database structure that sometimes requires extensive database queries to retrieve simple results. Reindexing the Magento indexers does not modify your existing data. It just queries your current data and copies it to its own tables. To reindex your Magento indexers, you can simply go to System > Index Management > Select All Checkboxes and from Actions drop down, choose Reindex Data > Submit.
Disable Magento Compilation
By default, Magento Compilation mode is disabled. So just to ensure if the Compiler is enabled, go to System > Tools > Compilation and hit the Disable button.
Enable PHP Display Errors
PHP display errors are likely to be disabled by default on web servers due to security and other reasons. You can enable PHP display errors using .htaccess file which can be found in the root directory of your Magento store. Just copy paste the code below at the top of the .htaccess file:
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_value error_log /home/path/public_html/var/log/system.log
Enable Magento Developer Mode
When an error occurs and your Magento store shows the error report page with useless error string like 1184257287824, you’ve got an option of enabling Magento Developer Mode. Magento in Developer Mode displays exceptions on the screen instead of showing a generic error message like “There has been an error processing your request.”
To enable Magento Developer Mode, put the following at the top of the .htaccess file under your Magento root directory:
SetEnv MAGE_IS_DEVELOPER_MODE true
Resetting the file and folder permissions of your Magento is necessary because incorrect ownership and permissions can cause a lot of problems and which are not that easy to find on first sight.
Change Magento Theme to Default
It is possible that the theme you are using is responsible for the issue you are facing. Reverting Magento theme back to default is a quick way to find out. But this step can also create malfunctions in your modules because they may be dependent on your theme features as well. If this resolves your issue, then you will have to dig deep to figure out which parts of the template are actually problematic.
Disable Local Modules
Similar to reverting Magento theme to default, you can also disable local, custom, and 3rd party modules and see if that works for you. It’s also a good practice to disable modules one by one, and if this step resolves the problem, you will have to figure out the problem by reading the code thoroughly.
Enable Magento Profiler
If you are facing performance issues, Magento Profiler can also help you here. You can optimize your Magento to run faster and can also fix your buggy codes which can ultimately decrease the page load time. To read more about it, I have also written a fantastic blog post on Magento Profiler.
If there is something fishy going on with the usual Magento code practices (which can sometimes be a nightmare), it’s a sound practice for any Magento Developer to adopt the best way to solve it: Magento Debugging.
We have lots of useful ways to make the Magento debugging process more handy and fast, and I have mentioned the most commonly used methods to solve Magento related issues. If you think I have missed something, feel free to share it in the comments section below.
Fayyaz is a Magento Community Manager at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. Fayyaz is a food lover and enjoys driving. You can email him at firstname.lastname@example.org
Start Growing with Cloudways Today.
Our Clients Love us because we never compromise on these