We are working on magento. but here we have to get product prices from another website using xml feed.

actually we are working on jewellery website using magento. we are adding products from backend. but gold prices are ups and down its depends upon market value. so how can i assign price to products. any sugguestions?

Thanks

diafol commented: Interesting question +14

Recommended Answers

All 16 Replies

I did a wedding ring site awhile ago, i did it by assigning each product the weight of the precious metal contained in it then having the price displayed on the page by doing: $price = ($goldprice*$goldweight);

So i would get the $goldprice to be pulled from the xml file and it will change live as the xml file changes

commented: I never heard anyone do something like this but your code make alot of sense and it will work +0
Member Avatar for diafol

I don't use magneto, so I'm not aware of how it works. If I was to design a system myself, with jewellery price based on the daily gold price. Say I fix a value for a gram at £30 (GBP). How about you set a base price for the item based on this value? When you get feed results from current price, you look to see the % difference from £30 and calculate the same % difference on your base price. You may wish to make the relationship non-linear though, so the greater the % increase in gold price from £30, the even greater % increase on the base price you get (up to a % limit, of course). Similarly you could have a minimum % below base price to which you'd go.

If the daily gold price changes substantially from your set standard (£30), it may be worth having some sort of routine to re-set your standard (e.g. to £40) and change the stored base price for all your gold products. Not knowing how much the price fluctuates, I have no idea whether this is how it should be done. Just my 2p.

Don't know if that's feasible for you.

Member Avatar for LastMitch

@muralikalpana

When I read your post. I never read or heard something like this for e-commerce website. I was very confused you mention

gold prices are ups and down its depends upon market value

Then I realizes that ... it's possible!
I live in the states, I live in NYC. I don't know where you live but I know in your country there should be a Commodity Futures Exchange like The New York Mercantile Exchange (NYMEX). They sell gold, silver etc. I used to work at the NYMEX for 6 months, it was a temporary position. It was my first job sadly. It has nothing to do with my BT degree.

First you need a Feed, I don't where you are from I apologizes for that, this is from the NYMEX where I used to work a long time ago.

Here is the link:

http://www.cmegroup.com/market-data/data-suite.html

Now you need a xml to help you with the prices and match your product:

http://www.morningstarcommodity.com/tools-apis/commodity-AddIn

so how can i assign price to products.

To assign the price to the product, you assign the end of the trading day (meaning the Market Exchange closes!) price to the product.

Then you will create something similiar to what Biiim example:

$price = ($goldprice*$goldweight);

plus you need an array for $goldprice but I think "Commodity Add-In for Microsoft Excel" do give you the that options.

I hope this will help. This is the only thing I could think of to match what you want.

Member Avatar for LastMitch

@muralikalpana

I think I didn't explain it clearly in my previous post I don't want to confuse you:

so how can i assign price to products.

To assign the price to the product, you assign the end of the trading day (meaning the Market Exchange closes!) final price to the product. (What I meant is that the Final Price (multiply) the Product )

Then you will create something similiar to what Biiim example:

$price = ($goldprice*$goldweight);

the $goldweight(is the product) plus you need an array for $goldprice but I think "Commodity Add-In for Microsoft Excel" do give you the that options, you can also download the template too, if that will help make things smoothly or you can create your own template.

So in the end, this is the same example as Biiim create but different words will work!

$price = ($goldprice * $goldproduct);

@Biiim,@lastMitch,@diafol

Thans for your replys.

@lastmitch:

ok at the end of the trading day i have to update my product rates. i will just update product table with new prices. am i right?

Member Avatar for LastMitch

@muralikalpana

Yes, when the market closes at the end of the day you used that price it's either dollars or cents. I mean I'm from the State so I'm using dollars or cents but if your country have a market then used your country currency.

The 2 links I provide is for like investment tools, for people who want to invested in Commodities. So to understand the formula you have to understand how to invested in it.

The symbol is GC which is gold. You have to create a 5 day showing the chart price fluctuation. Then now you have to create a formula on the excel sheet to calcuate gold price per day, you have convert dollars or cents in to troy ounce. The price fluctuation on the NYMEX is $0.10 (10¢) per troy ounce. For example if it's 60 cents then it's 6 troy ounces. I forgot how formula works I think I'm missing some steps on the excel, It's been like 10 years now it's hard to remember something like this. Once you get the gold price you can figure out the worth of your gold jewelry by

K= karats of your gold jewelry
W= weight of your jewelry in ounces/grams

Once you sign in at the Data Suite and create a profile for the Morning Star download a template from the Morning Star and open that excel sheet and select Query then it will upload the live feed. Then you edit or create a new template, to find the formula you click on the Commodity Add-In for Microsoft Excel. It will should you a lot of formula. There's a formula that convert the Units and Currency Conversion and there a formula that used the price fluctuation. Hopefully that will help you get you started. It shouldn't take you that long to create the formula because I gave you alot of details, it's just that I forgot which steps goes first and missing some details and steps. You can try to search for the formula on google but it's hard because not much people used those formulas unless you broker or trader. If you have problem just post the excel formula and I'll try remember it immediately. So I apologize this is all I remember.

K= karats of your gold jewelry
W= weight of your jewelry in ounces/grams

Thats a good point, if the karats vary you will need an extra calculation to make it easy on data entry.

24 karats = 100% so it would be something like this:

<?php
$row[0]['metal'] = 'gold';
$row[0]['karats'] = '22';
$row[0]['weight'] = 31.1034768;//grams
$row[1]['metal'] = 'gold';
$row[1]['karats'] = '24';
$row[1]['weight'] = 31.1034768;//grams
$row[2]['metal'] = 'silver';
$row[2]['karats'] = '24';
$row[2]['weight'] = 100;//grams
$metalPrices['gold'] = 3284.4238;//pence per gram
$metalPrices['silver'] = 56.3603;//pence per gram
foreach($row as $k=>$v){
    $productPrice = round((floatval($v['weight'])*($metalPrices[$v['metal']]*(floatval($v['karats'])/24)))/100,2);
    //weight*(metalprice*karats/24)
    echo $v['metal'].'--'.$v['weight'].'g--'.$v['karats'].'K--&pound;'.$productPrice."<br/>\r\n"; 
}
?>

On the site i did there was also mixed metal rings, such as platinum and gold where there was also just a "mixed" metal price too

ok at the end of the trading day i have to update my product rates. i will just update product table with new prices. am i right?

Yeah, the key is to write it so all you have to do is update the base metal price and everything updates, so you get $metalPrices to pull its data either from a metal price feed or in a mysql table where you can manually update it at the end of the day, you could even add a 5% margin on the prices or VAT but that might be insulting your intelligence!

just make sure the data is the actual spot price or things will get confusing code wise

Member Avatar for LastMitch

@Biiim

Nice work with the code! It's a bit to advance for me at this point, actually this topic is more complex.

On the site i did there was also mixed metal rings, such as platinum and gold where there was also just a "mixed" metal price too

That is very interested how you did that. Did you put a cap on the platinum and gold? Meaning like for example: This watch cost 120 pounds and if the platinum and gold rises each day, the price of the watch increases too, if it keeps increase at a certain point it has to stop, like the cap will be 15 pounds if it reaches at (120 + 15 = )135 pound, it will stop increase same as if the price decrease to (120 - 15 = )105 pound.

May I ask what feed are you using? I know you are from UK. So it's one of those stock exchange. Plus, this is something very complicated. For example, since you are from UK and I'm from the states and I was to buy gold from your website. Base on the currency rate, the total cost to buy that jewelry will be much more expense because the Pound is worth more than a US dollar. How do you put that on the shopping cart (e-commerce website)?

K= karats of your gold jewelry
W= weight of your jewelry in ounces/grams

The gold price will be in UK Pound plus K & W, the jewelry will cost more for me to buy base on the Pound.

That is very interested how you did that. Did you put a cap on the platinum and gold? Meaning like for example: This watch cost 120 pounds and if the platinum and gold rises each day, the price of the watch increases too, if it keeps increase at a certain point it has to stop, like the cap will be 15 pounds if it reaches at (120 + 15 = )135 pound, it will stop increase same as if the price decrease to (120 - 15 = )105 pound.

I didn't put in a live feed, i added an admin backend where the site owner could just set the price per gram of the metals, mixed wasn't worked out by a combination it was just its own set price, its not too hard to switch it to a live feed though just need something like this: http://www.w3schools.com/php/php_xml_simplexml.asp

Base on the currency rate, the total cost to buy that jewelry will be much more expense because the Pound is worth more than a US dollar

I dunno if thats true, supply and demands are different in different countries so prices for things can cost more or less - the exchange rate makes the money worth the same though you can see this especially in gold since the value is pretty standard worldwide:

1g gold in usd = $51.11 = £32.955
1g gold in gbp = £32.89 = $51

likely means theres a slightly higher demand for gold in the US atm

Member Avatar for LastMitch

@Biiim

I didn't put in a live feed, i added an admin backend where the site owner could just set the price per gram of the metals, mixed wasn't worked out by a combination it was just its own set price, its not too hard to switch it to a live feed though just need something like this: http://www.w3schools.com/php/php_xml_simplexml.asp.

You are Clever Developer! Not sure if the site owner would actually set the price higher on the metals base on assumption plus the Economy is pretty bad everywhere.

1g gold in usd = $51.11 = £32.955
1g gold in gbp = £32.89 = $51

You done your research! =)

It's good to see you are doing well!

I am using magento for my jewelry site, and i want to update my gold jewelry prices on the basis of current gold price. I was thinking to acheive this by cron job. But magento uses cache to improve website performance and daily price update will affect site loading time. Please let me know some better solution...

Member Avatar for diafol

I'm not acquainted with Magneto at all, but you can cache blocks ofa page or sql results separately. I'm assuming that Magneto doesn't only do page-level caching?

@Biiim

I did a wedding ring site awhile ago, i did it by assigning each product the weight of the precious metal contained in it then having the price displayed on the page by doing: $price = ($goldprice*$goldweight);

So i would get the $goldprice to be pulled from the xml file and it will change live as the xml file changes

I would like to do something like this on a site I'm working on. How were you able to assign each product the weight of the precious metal?

Thanks for your help.

You can manage such calculations much better with the fineness. And Karat is only for Gold. For instance:

$currentMetalPricePerGram * $weight * $fineness = Price

And this is valid for all Precious Metals.

If you need the live prices, you can get it here: Precious Metals XML Price Feed

Greetings.

I saw an interesting solution recently - a private sale script from Plumrocket. A number of magento extensions and magento private sales theme. And there you can find an extension RSS Feed Generator, allows you to easily create custom magento product feed as well as rss feeds for categories. I think you can find it on their site, maybe you'll find it valuable for yourself.

Member Avatar for diafol

Are you advertising Plumrocket?
PR is being flagged for attention by the odd spammer here. Not accusing PR or you. If you could provide a direct link to this, it may help others.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.