The current project I’m working on has something special: each client has its own price, but this price is not in Magento but in an Oracle DB. Every client on the website has a client id related to the Oracle DB, and in the Oracle DB there is a discount that is different for each client.

The possibility of adding all these price rules for each client in Magento is discarded. Then, the solution is getting that discount and applying it to the product price. This means that the final product price is different for each client (OK, that was our goal).

At this point, we have to find out how to apply that discount to the product price and set the new price in Magento. This is what I’m going to explain in the following lines.

Creating a module

First of all, we need to create a custom module for this. I’m not going to explain how to do so. Go to the Alan Storm (what a cool name!) website and learn!

Once you have created your module, your etc/config.xml file should look like this:

<?xml version=";1.0"; encoding=";UTF-8";?>

Here we are rewriting the method that gets the final price. Now its time to create the observer. Create a Model/Observer.php file and paste the following code:


class COMPANY_CustomPrice_Model_Observer

 public function __construct()

 public function get_final_price($observer)
  /* Check if the customer is logged in, if so, then we proceed (this can be done on the xml using <customer_is_logged_in> (or something like that...)  */

   $customer_id = Mage::getSingleton('customer/session')->getCustomerId();

   /*Do whatever you need to get the custom discount for this client

   $discount = 0.3;

   $event = $observer->getEvent();
   $product = $event->getProduct();
   $product->original_price = $product->getPrice();

   $final_price = $product->original_price * (1 - $discount);


   return $this;

What now?

Now that we know how to set the a special price manually, there are going to be a lot of conditions to take into the account depending on our website. In my case, we only apply a special price for registered clients that have been assigned an special id (different than the magento client id).

Note that this change is being applied only on the product page, not on the product list. This is because, in my case, we have to get the price from an Oracle DB that takes its time to return the result. If it’s only a single product, then it’s OK, but if we need to get more results, it takes longer.

There are also other things to take into the account: is this the best way to change the price on the product price? How about changing the price directly and not setting a «special price»? I’ll find out and write about it (here or in a new post).

This works in Magento CE and EE


Alex · December 12, 2011 at 7:47 pm

Hi guys,

Please check our solution for this problem “Customer Group Prices”

Regards, Alex

    magenting · December 12, 2011 at 7:57 pm

    Hi Alex,

    What’s the difference between this extension and using tier prices?

      Alex · December 12, 2011 at 8:07 pm

      When you use Tier Prices user can see your default price. For example it will display Price 300$.
      Buy 1 and get 50% discount.
      And when you use our extension nobody will see the default price. It means that user from Wholesale group will see prices only for this group. Our extension also works with special prices, tier prices.

      Regards, Alex.

PAU · May 19, 2016 at 12:10 pm


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.