user2753425 user2753425 - 1 year ago 87
PHP Question

how to implement dynamic calculating price in magento based on weight ?

Hi i’m developing a eCommerce site in Magento for jewellery business and its based on a “weight”, not the price because gold rate is changing in day by day or more then 3 times in a day.So it is not possible to change the product price every time according to gold rate. Then, how to manage the prices on this scenario?

Example case: Today I have added a 18K gold ring of 10gm to my site and right now gold rate is Rs30,000 per 10gm, so today price of this ring is Rs30,000 but, Next day the rate will be changed (Rs32,000 per 10gm) then, my product price must be changed from Rs30,000 to Rs32,000.

This is not possible to update the price of all products every time.
I am using Magento platform. Please, Share your idea regarding this situation.

Answer Source

To make this simple, you should work on a 2 ways solutions.

In the frontend, do not show price ($_product->getPrice()) but just show the real price according to weight.

Example if you have price/grm stored in the backend use $product->getWeight * Mage::getStoreConfig('mycompany/gold/dayprice').

That way price will be shown dynamically in the product page or list page.

Now you should use an Observer on the add to cart event to change the price to the good one.

This way, don't matter what price is set on the product because showing and adding will use the formulae.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download