Skip to content
Advertisement

Magento 1 – Where does Magento Set a Quote Item’s Price?

Whenever you load the cart page in Magento, the following code is run

$cart->init();
$cart->save(); 

One side effect of this is that the prices for any items in the cart are updated if the price of the product has been updated. This actually updates the entry in sales_flat_quote_item. I’m trying to track down where in code the price is updated on each quote item, and where each quote item is saved.

I know the myrid locations it could be set. I’m hoping someone knows where it actually is set. Magento 1.7x branch specifically, although info from all versions is welcome.

Advertisement

Answer

From a high level, the code that starts the whole process are lines 464 and 465 of Mage_Checkout_Model_Cart :

 $this->getQuote()->collectTotals();
 $this->getQuote()->save();

The new product price is being set against the quote in Mage_Sales_Model_Quote_Address_Total_Subtotal in the _initItem method. You will see $item->setPrice in the the if / else statement starting at line 104

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement