I am using the following code to set the product to the quote object

$quote->addProduct($product,new Varien_Object(array('qty'   => $productid)));

The product and it's quantity is stored in the sales_flat_quote_item table on saving the quote but the price and base price is 0. The price is not set with the price of the product.

1 Answer 1


You need to call function collectTotals() before saving your instance of Mage_Sales_Model_Quote.

Proper code block would look like this:

$productId = 1;
$productQty = 15;

$product = Mage::getModel('catalog/product')->load($productId);

$quote = Mage::getModel('sales/quote');
$quote->addProduct($product, new Varien_Object(array('qty'   => $productQty)));

$quote->collectTotals(); // This is the line you're missing
  • Yes I used it like this $quote->collectTotals()->save(); but it didin't work
    – jackson5
    Apr 28, 2017 at 9:06

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.