This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

📣 Join the live AMA session with Adam Silverstein on open source and WordPress core! Register Now →

How to Debug a Magento Store Code

Updated on December 24, 2021

4 Min Read
Debug Magento Store

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.

How To Debug A Magento Store

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

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.

You can check Magento logs from the admin panel or in your Magento server.

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.

If you are using any other sources of cache like Varnish, Memcached, or Redis, you have to clear their cache manually.

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

Reset Permissions

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.

Conclusion

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. Also we have got you covered for debugging Magento 500 and Magento 503 errors and it’s solution too. If you think I have missed something, feel free to share it in the comments section below.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Abdur Rahman

Abdur Rahman is the Magento whizz at Cloudways. He is growth ambitious, and aims to learn & share information about Ecommerce & Magento Development through practice and experimentation. He loves to travel and explore new ideas whenever he finds time. Get in touch with him at [email protected]

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now