Magento: How to get SQL query of Product load?

load() is actually the method which execute query on database. For that reason there is no option to "find such for product load()". Final query is generated before load() method.

Additionaly, easier method to get query on the screen for example is (on your example):

$collection = Mage::getModel('catalog/product')->getCollection();
echo $collection->getSelect()->__toString();

You can dump the actual query via

To enable SQL Debugging, Go to

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

change line 98

protected $_debug = false;

to

protected $_debug = true;

It will write the SQL straight to the value of line 126

protected $_debugFile           = 'var/debug/pdo_mysql.log';

Tags:

Sql

Magento