What is the full SQL query for product load?
I mean, how to get the full SQL query for this code:-
$productId = 52;
$product = Mage::getModel('catalog/product')->load($productId);
I know, we can get the SQL query for collection object through printLogQuery. Example:-
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->printLogQuery(true);
I couldn't find such for product load(). Any idea?
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';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With