I have a store with different customer group.in which all customer has a specific discount for all product.Suppose customer group A has 10 customer and discount is also 10% on all product. Discount is decided from one of my API site so it's a real time discount for different customer group When customer logging in that belongs to customer group A he/she is able to see price with 10% discount every where (Product listing,product view,and with whole check out process.)

i can achieve this by calling below code but it display only on cart page not every where.


observer function

$item = $observer->getQuoteItem();
     $product = $observer->getProduct();
     $price = $product->getPrice();
     // Discounted 25% off
     $percentDiscount = 0.25;

     // This makes sure the discount isn't applied over and over when refreshing
     $specialPrice = $product->getPrice() - ($product->getPrice() * $percentDiscount);
     // Make sure we don't have a negative

How can i achieve this Please help

2 Answers 2


Depending on how much products, storeviews and customer groups you have, it might be an idea to just import the discount rules as catalog price rules.

The problem with this is, that the rules are generating an index with the size

#product * #storeviews * #customer_groups

So if these counts are not so high, just add new catalog rules, save them and magento will do the rest for you.


The prices for products in the catalog are displayed from the getFinalPrice method in the clas Mage_Catalog_Model_Product that is used in the catalog category list and the product view page. Rewriting this function will enable you to show a different price per customer but that is only half of the catalog.

A bit more complicated will be the layared navigation and advanced search since these get their price from an index. Rewriting this will be a lot more tricky so you might just want to leave that out of scope.

The price displayed in the cart (quote) and later on in the order, invoices and shipments is a lot more simple. Check out this stack overflow answer that uses an observer to modify the price in of the quote item. After that the item prices will also be passed along to the order and further along.

Your Answer

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

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