I am using Magento 2.3.4

Can we print a SQL query when product search from admin product grid?

I can print sql queries in our custom or product collection in frontend using


but I want to print the SQL query in the admin product grid.

1 Answer 1


You can use magento cli command: bin/magento dev:query-log:enable

This will enable logging for all sql queries. It's not a perfect solution, but you will be possible to find needed sql.

Magento docs: https://devdocs.magento.com/guides/v2.4/config-guide/cli/logging.html#to-enable-database-logging

  • it is not print SQL query,it just show json fields and their values Oct 20, 2020 at 14:42
  • No, please check var/debug/db.log in your project. There you can see all sql queries which were executed after db query logging enabling. Oct 21, 2020 at 8:31
  • It may need to flush cache bin/magento cache:flush after enabling/disabling query log. Jun 24, 2022 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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