Magento Forum

Auto Update Product Prices Using XML Feed
 
arctic_gardener
Jr. Member
 
Total Posts:  2
Joined:  2013-01-29
 

I’m working on a magento shop that sells precious metal coins and bars of different weights. 

The price for each product needs to change with the spot gold price as it changes throughout the trading day.  At the moment I have less than 10 products that require this treatment, but would like to find a solution that can be added to easily.

Example of what I’m aiming for:

Monday at 1pm precious metals are trading on the open market and gold spot is at $1600 per oz.  I’m selling a 1 oz gold coin in my shop that gets its price from this $1600 number and displays to customer: 1 oz gold coin $1650. ($50 added for markup) Now 20 minutes later on Monday, spot gold moves up to $1615 per oz, and my shop automatically changes the price customer sees for this 1 oz gold coin to $1665.

Different products made from gold would all be based on this spot gold number that changes, but would also each have a unique $ amount markup that would be either fixed or percent added.

A calculation to achieve desired result might be:
1oz gold coin price = goldspot * 1 + $50 markup
1/4oz gold coin price = goldspot * 0.25 + $20 markup

It looks like the gold spot price can be acquired through an xml feed that updates every few minutes, but I’m not sure how to apply these updating values to my products.

How can this be accomplished?

If a new product needs to be added, is there a simple way to input the markup and weight for that product and then have the “goldspot” multiplied by the weight + markup = price?

I’m really new to all this, so any help would be greatly appreciated.  Perhaps you could point me in the right direction if this question in part has already been addressed elsewhere.

Thanks so much.

 
Magento Community Magento Community
Magento Community
Magento Community
 
arctic_gardener
Jr. Member
 
Total Posts:  2
Joined:  2013-01-29
 

Thanks for the reply Vanquish.

At this point, since I have less than 10 products that need prices auto updated throughout the day, I’m still hopeful that I can implement something myself that will work.

One more detail is that I’m dealing with multiple types of metal.  I would like to be able to specify during product creation in the back end which metal price the new product should be associated with, and perhaps even the weight of the product so the price calculation would check these variables and display the appropriate amount.

Product 1
type: gold
weight: 1 troy oz
markup: $50

Product 2
type: silver
weight: 10 troy oz
markup: $19

etc…

Does this make sense?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ryan Sun _Kuafu
Guru
 
Total Posts:  317
Joined:  2008-11-14
FL
 

you will create a cronjob observer and set it to get latest gold price from market(I believe there is a web service) every monday 1pm
then get a collection of products and update price.

 
Magento Community Magento Community
Magento Community
Magento Community
 
arctic_gardener
Jr. Member
 
Total Posts:  2
Joined:  2013-01-29
 
Ryan Sun _Kuafu - 05 March 2013 08:24 PM

you will create a cronjob observer and set it to get latest gold price from market(I believe there is a web service) every monday 1pm
then get a collection of products and update price.

How do I setup a cronjob that will get the gold price from the xml feed?

The XML file looks something like this:

<prices>
<currency access="usd">
<price access="gold">50.91713</price>
<price access="palladium">23.9523</price>
<price access="platinum">51.28044</price>
<price access="silver">0.93205</price>
</currency>
</prices>

Do I assume correctly that the data in this feed will need to be processed somehow before Magento can use it to update product prices?

Thanks for helping on this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
webtecz
Jr. Member
 
Total Posts:  1
Joined:  2013-06-22
 



Dear friends,

I am also working on a similar site with golds products, and facing same problem with spot rate, is there any utility like currency webservice to update the rates of gold.

I am also new and needs your support.

Thanks in advance.



 
Magento Community Magento Community
Magento Community
Magento Community
 
GoldMann
Jr. Member
 
Total Posts:  1
Joined:  2013-06-26
 

Dynamic Product Pricing for Precious Metals

To do this, I would recommend setting up a table in the database to store the latest spot price from the data source (XML feed). Many of these feed providers offer a subscription to access their spot price data. Some of them have “hit restrictions” on the frequency that you can retrieve the data.

The table in the database will store the most current spot price and the date/time it was last updated (mysql “timestamp")

Then in your script, you can set it up to only hit the data source if the timestamp of the record in the database has been longer than (however long you want the interval to be) ago.

For the XML example shown in the earlier posting, that is gram price so a formula will have to be used to convert that to price per troy ounce if the weight measure you will use for pricing is troy ounces. (gram price * 31.1034768 = troy ounce price)

For a precious metal product with a high purity (.999 or better) the metal value can be fairly calculated (product price = gram price * 31.1034768 * troy ounce weight)

When a product contains multiple metals, the percentage is needed for each that make up the product as shown in example below.

Example: $50 American Gold Eagle

Total Weight: 1.0909 troy ounces

Gold Percentage: 91.67%
Actual Gold Weight: (.9167 * 1.0909 = 1.0000 troy ounces)
Actual Gold Value: (1.0000 * gold troy ounce price)

Silver Percentage: 3.00%
Actual Silver Weight: (.03 * 1.0909 = 0.0327 troy ounces)
Actual Silver Value: (0.0327 * silver troy ounce price)

Copper Percentage: 5.33%
Actual Copper Weight (.0533 * 1.0909 = 0.0581 troy ounces)
Actual Copper Value: (0.0581 * copper troy ounce price)

Product Metal Value = Actual Gold Value + Actual Silver Value + Actual Copper Value

Usually, products of this type are priced with an additional cost over the current Product Metal Value.

For this example let’s say the additional cost is $20.00 (this is $20.00 per troy ounce)

Price Over Spot = Total Troy Ounce Weight * $20.00

Total Product Price = Product Metal Value + Price Over Spot

Ok, now you have retrieved the XML data, stored it, and calculated prices based on it. Those prices have to be stored for the time interval that you desire. (1 minute, 5 minutes, 1 hour)

If the website has 50 concurrent visitors, it will be crucial to be using the stored spot price data in your own database. Using a quick date comparison will let the script know if it is time to go out and retrieve an updated XML spot price based on the interval that you choose.

If the timestamp in your database for your spot price data is greater than (your interval) ago, then hit the XML feed and read the new prices.
It is a sort of “wash, rinse, repeat” process that needs some control. When you don’t have visitors and if you want to keep a log of spot prices to build charts or price history features into the site, then a chron-job can be set up on your host to call the same script that normally performs the XML read at the interval you specify.

The way I set mine up, the interval is 5 minutes for the chron-job and 1 minute when there are active website visitors. I implemented a global price update feature so everyone’s cart items change with the price coming from the XML feed. For my product pricing, I don’t use the actual value of the product, I use the amount over the Product Metal Value that I want to charge for the product.

When I add a new product, I enter the troy ounce weight, metal percentages and price over spot that I want to charge. The spot prices do the rest.

It took about 2 weeks to get it programmed and fine-tuned without any bugs but it is real real-time pricing.

 
Magento Community Magento Community
Magento Community
Magento Community
 
citychannel
Jr. Member
 
Total Posts:  1
Joined:  2010-12-06
 

GoldMann have you any interest in setting this up for me on a site that requires the Dynamic pricing for precious metals? Drop me an email at with a estimate on pricing please.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GoldPriceLive
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2013-10-06
Edmonton, Alberta, Canada
 

Hi there. There is now an extension that will take care of this for you.

You can find it in Connect at: http://www.magentocommerce.com/magento-connect/gold-price-live.html

It allows you to enter weight, markup ($ or %) and purity of your item.

Not sure if you found a solution but for others this may help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
GoMageTeam
Guru
 
Avatar
Total Posts:  356
Joined:  2013-01-13
Warsaw, Poland
 

Hello,

If you use GoMage Feed Pro extension, you can create the feed file, generates and exports it to a shopping engine. Then you have the option to set up the feed file to be updated and uploaded automatically. It will updates the products price too and you don’t need to do it manually and waste your time.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top