Sunday, February 8, 2015

Debugging Magento

1. Turn on Template Path Hints

Admin > System > Configuration > select the current configuration scope to website store view > Developer > Template Path Hints to Yes.

2. Turn on error/system logging

Admin > System > Configuration > Developer > Log settings > Enabled to Yes.

3. Turn on SQL logging

Edit lib/Varien/Db/Adapter/Pdo/Mysql.php

Change: protected $_debug = false;
To: protected $_debug = true;

4. Display PHP Errors

In index.php, add the following lines:

ini_set('display_errors', 1);

5. The Magento error setting.

copy errors/local.xml.sample to errors/local.xml

6. XML parse tool

If you're running on Linux, you have xmllint to help ferret out layout xml file mistakes and malformation.

7. Set php options in .htaccess

8. Magento logging functions



9. Get MySQL query string

$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToFilter('small_image', array('notnull' => ''));
$collection->setOrder('name', 'asc');
echo '<pre>' . $collection->getSelect()->__toString() . '</pre>';

No comments: