I need to know which price function is called when product is added to cart as i have overridden the function getFinalPrice() but still when product is added to cart it takes the default price. Why ?


2 Answers 2


You can change the product price while add to cart via Event to listen to checkout_cart_product_add_after by following code:
In your /app/code/local/{namespace}/{yourmodule}/etc/config.xml:


And then create an Observer class at /app/code/local/{namespace}/{yourmodule}/Model/Observer.php

class <namespace>_<modulename>_Model_Observer
    public function modifyPrice(Varien_Event_Observer $obs)
        // Get the quote item
        $item = $obs->getQuoteItem();
        // Ensure we have the parent item, if it has one
        $item = ( $item->getParentItem() ? $item->getParentItem() : $item );
        // Load the custom price
        $price = $this->_getPriceByItem($item);
        // Set the custom price
        // Enable super mode on the product.

    protected function _getPriceByItem(Mage_Sales_Model_Quote_Item $item)

        //use $item to determine your custom price.

        return $price;


This is depends on your product type. default class is Mage_Catalog_Model_Product_Type_Price.

You can open config.xml in catalog module

                <simple translate="label" module="catalog">
                    <label>Simple Product</label>
                <grouped translate="label" module="catalog">
                    <label>Grouped Product</label>


here price_model, tag is the actual price model by product type.

  • Thanks for your reply but does this way will effect other rules of pricing like shopping cart price rule and other tax functionalities because it will set the custom price directly to cart ?
    – Sarvagya
    Jan 6, 2014 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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