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.
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.
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.
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:
There are modules which can help you easily track these down.
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.
Commerce Bug 3 is an amazing toolbar for showing tons of info on what is happening on a particular page.
Adminer is a single PHP file to manage your database. Adminer has a fast search that can search all database tables for your keyword.