I want to see the mysql query when adding a product to the cart. I have referred this link, How to log all Magento 2 SQL queries? but I need query only for cart.

How to get the query for cart events? Can anyone please guide?

Thanks in advance!

1 Answer 1


I think you should look at adding some logging to the \Magento\Quote\Model\Quote::addProduct method.

If you want to log the MySQL commands server-side, you might have to add logging at a very low level. After adding items to the quote entity, the quote will be saved to the database via \Magento\Framework\Model\ResourceModel\Db\AbstractDb::save method. This method is used to save all entities to the database though, so you'll have to be very defensive in your logging etc.

Your Answer

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

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