1

I'm trying to get the raw sql query Magento is running on the database to select the data for the report grid. I can print the collection query string with

$collection->getSelect()->__toString()

but this does not contain the filters. But I need the query with filters. Thanks for any help

1
$collection->load();
$collection->getSelect()->__toString()

Should work. If you are using an EAV collection you have the problem, that the first query (the one you see) only loads IDs which applied the filters and afterwards loads the attributes (you don't see this query).

With @Phil's answer you see everything, which might be a little bit confusing but complete :-)

| improve this answer | |
1

Go to lib/Varien/Db/Adapter/Pdo/Mysql.php and set the following variables to true:

protected $_debug
protected $_logAllQueries

You'll find the queries in var/debug/sql.txt

(Thats the only option I know though, there are probably better ones)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.