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:

error_reporting(E_ALL);
ini_set('display_errors', 1);
$_SERVER['MAGE_IS_DEVELOPER_MODE'] = true;

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

Mage::log(print_r(get_class($_product),true));

Mage::log(print_r(get_class_methods($_product),true));

9. Get MySQL query string

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

No comments: