Answer the question
In order to leave comments, you need to log in
Why is it wrong to multiply?
Good evening, the essence of the problem is this. It is necessary to parse the xml file and save it in yml, which is suitable for loading into the CMS.
The problem is the following in the source file there are currency tags in which the courses are registered.
<currency id="EUR" rate="27.5840"/>
<currency id="RUB" rate="0.3760"/>
<currency id="USD" rate="24.8500"/>
$eur = $xmlProducts->currency[0]->attributes()->rate;
$rub = $xmlProducts->currency[1]->attributes()->rate;
$usd = $xmlProducts->currency[2]->attributes()->rate;
$price = $offer->appendChild($xml->createElement('price'));
if($product->currencyId == 'USD'){
$price = $price->appendChild($xml->createTextNode($product->price * $usd));
SimpleXMLElement Object
(
[0] => 24.8500
)
SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 382
[selling_type] => u
)
[name] => Дельфины коврик для крышки унитаза
[categoryId] => 900064
[price] => 4.43
[currencyId] => USD
[image] => Array
(
[0] => https://b2b.antey.com.ua/media/product_sku_000382_0.jpg
[1] => https://b2b.antey.com.ua/media/product_sku_000382_1.jpg
)
[vendor] => KERAMAC
[vendorCode] => SimpleXMLElement Object
(
)
[param] => Array
(
[0] => Винил
[1] => Другие цвета
[2] => KERAMAC
[3] => Flori
)
[description] => Дельфины коврик для крышки унитаза, винил
[available] => true
)
<offer id="382">
<name>Дельфины коврик для крышки унитаза</name>
<categoryId>900064</categoryId>
<price>96</price>
<description>Дельфины коврик для крышки унитаза, винил</description>
<vendorCode></vendorCode>
<vendor>KERAMAC</vendor>
<param>
<param name="Материал">Винил</param>
<param name="Цвет/тип покрытия">Другие цвета</param>
<param name="Бренд">KERAMAC</param>
<param name="Серия">Flori</param>
</param>
</offer>
Answer the question
In order to leave comments, you need to log in
There is not enough float precision, for exact monetary calculations there is moneyphp/money
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question