I believe it should be made when we add an item in cart, but I need to find code in Magento core where quote ID is generated and an object is made and similarly in the DB.

2 Answers 2


Yes, the quote is created as soon as you interact with the cart for the first time in your current session.

In the code, the object gets created in Mage_Checkout_Model_Session::getQuote(), if no quote id is stored in the session yet:

 $quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId());

and saved to the database in Mage_Checkout_Model_Cart::save()


Most probably you are looking for app/code/core/Mage/Checkout/Model/Cart.php -> public function save() -> lines:


which calls app/code/core/Mage/Sales/Model/Quote.php -> public function save().

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.