Magento Wizard | Lakewood Colorado Magento Web Design, E-Commerce, Online Marketing, SEO

Lakewood Colorado Magento Web Design, E-Commerce, Online Marketing, SEO

Magento Wizard | Lakewood Colorado Magento Web Design, E-Commerce, Online Marketing, SEO
  • Portfolio
  • About
    • About Me
    • FAQ
  • Services
  • Blog
  • Contact Me

Debugging Magento

Debugging Magento

Posted on
November 3, 2017
by Chris Rosenau

One of my strong suits is debugging Magento. Hopefully this will help other Magento developers who struggle with tracking down where an issue is occurring.

Blocks

Making blocks visible to you and getting info on which template files are displaying which code, is very helpful. This is standard Magento functionality found under System->Configuration->Developer->Debug. Just change the site scope and clear the cache. Now you will see the blocks and their templates surrounded in red.

Logs

My first stop is always logs. There is the standard Magento logs in var/log. I usually start with this command so I can watch for errors:

tail -f system.log

If the error is more serious, I will checkout the exception log. If we are lucky, we might get a report of the error from Magento. In this case you will get a number for the report and can look at the report in var/report.

Most developers in Magento 1 will use Mage::Log($foo); to output info in code to the system log. Just make sure you add some info to tell you where you put this code. For example:

Mage::Log('Shipping module controller: '.$foo);

That way if you forget to remove your logging code, it can be easily found and removed by you or other developers.

In Magento 2, you will need to use these commands to output to the correct log file:

$this->_logger->addDebug($message); // log location: var/log/system.log 
$this->_logger->addInfo($message); // log location: var/log/exception.log 
$this->_logger->addNotice($message); // log location: var/log/exception.log 
$this->_logger->addError($message); // log location: var/log/exception.log 
$this->_logger->critical($e); // log location: var/log/exception.log

Finally you can check the server logs, usually located in /var/log/ and check out Mysql, Php, Apache or Nginx error logs.

Conflicts

Modules often times use the same core Magento methods and thus one module can have parts of it not function correctly. In this case you will need to have one of the modules extended it’s class from another module using the same core method. If you have n98-magerun installed, you can run this command:

n98-magerun.phar dev:module:rewrite:conflicts

There are modules which can help you easily track these down.

Alekeon Module Detector

Boost my Shop Magento Extension Conflict

Extendware Extension Conflict

Template File Overrides

A very common issue, is when a module’s template file is located in the base directory and has been customized and put into the theme directory. Then when someone upgrades the module, the module template file located in the theme directory will override the one in the base directory causing errors. The best approach is to take the base template file and upgrade the code with the changes in the theme directory. Then replace that upgraded template file with the one in the theme directory.

Another issue can be files found in app/code/local/Mage/. These files override the core files. If Magento has been upgraded or patched, these can be defunct and cause problems. It is wise to review these and see if they are still needed. In many cases it would be better to move these into their own custom module.

Developer Tools

Commerce Bug 3 is an amazing toolbar for showing tons of info on what is happening on a particular page.

PHPStorm is an IDE that is very powerful, especially when you combine it with Magicento and Xdebug.

Adminer is a single PHP file to manage your database. Adminer has a fast search that can search all database tables for your keyword.

Blog tags: magento

Recent Posts

  • WordPress 5 Classic Block
  • WordPress 5 Expand Post/Page Editing Area
  • Magento 2 module creator
  • Microservices + Events + Docker = A Perfect Trio
  • Code This Not That Javascript

Archives

  • December 2018
  • November 2018
  • October 2018
  • August 2018
  • March 2018
  • November 2017
  • October 2017
  • August 2017
  • May 2017
  • January 2014
  • December 2013
  • October 2013
  • September 2013
  • March 2013
  • June 2012
  • September 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010

Categories

  • Blog
  • demo
  • movie
Follow me on Mastodon
© 2024 Magento Wizard. All rights reserved
  • Privacy Policy