I wonder how the dynamic pricing works in Magento?

For example I have created product in the backend and add some custom options to it. So, if user choose the option, the price change automatically on the product view page without reloading the page.

Can anybody explain how Magento perform this action?

And can we add custom dynamic pricing? I want if user click the link (I added to product view page), then the price change.

2 Answers 2


Price calculation is a very complex topic in Magento. Here is a bird's eye view on how this is done for a simple product:

  1. Magento gets the "base" price. This is the price you have defined in the price column
  2. The "group" price is applied. This is the part where the tier price is taken in consideration based on the ordered quantity, website and customer group.
  3. The special price is applied if a special price is defined for the current date.
  4. The "catalog_product_get_final_price" event is fired. This is where your custom module that tinkers with the price should come in. As a working example, the CatalogRule module catches this event and changes the price based on the defined catalog rules
  5. The prices of the selected options is taken into consideration

Since this process is extremely time consuming, Magento creates a price index and will go through the above only when reindexing. The price index makes use of a bunch of tables that has info about the "final" price (calculated using the steps above) along with things like minimum / maximum prices for configurables and bundles. This table has an entry for each website/product/customer group combination, so the system will only need to select the proper row based on the customer data, making the whole process run in decent time.

As for the frontend part, the way the price is dynamically increased and decreased, this is all done in javascript that starts with a json array with all the "price levels" and will decrease/increase the price based on your selections.

  • Thanx Paul for your answer. Magento dynamic pricing is a complicated topic :)
    – Wakanina
    Mar 5, 2013 at 8:36
  • using "catalog_product_get_final_price" event and setFinalPrice() change the price in product view page and further steps. But how can I set the dynamic price right from product list page?
    – Shathish
    Dec 4, 2013 at 6:37

This is done with Javascript and Ajax, if I'm correct it's located in the file js/varien/configurable.js. If you want to change the behaviour of this you could use prototyping to extend the specific function. Im not to good with javascript but I think this Stackoverflow article explains the basics of extending https://stackoverflow.com/questions/2686258/javascript-inheritance-extend-function

  • Thanks Sander, this makes it little clear :). Does anybody can explain more details? This will be valuable for everyone.
    – Wakanina
    Mar 3, 2013 at 12:19

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.