diff --git a/src/Sylius/Bundle/CurrencyBundle/Resources/config/services.xml b/src/Sylius/Bundle/CurrencyBundle/Resources/config/services.xml index faa7d930121..c2d4c4e501e 100644 --- a/src/Sylius/Bundle/CurrencyBundle/Resources/config/services.xml +++ b/src/Sylius/Bundle/CurrencyBundle/Resources/config/services.xml @@ -25,6 +25,8 @@ Sylius\Component\Currency\Importer\EuropeanCentralBankImporter Sylius\Component\Currency\Importer\OpenExchangeRatesImporter + Sylius\Component\Currency\Importer\CzechNationalBankImporter + Sylius\Bundle\CurrencyBundle\Form\Extension\MoneyTypeExtension Sylius\Bundle\CurrencyBundle\Form\Type\CurrencyChoiceType @@ -60,6 +62,11 @@ + + + + + diff --git a/src/Sylius/Component/Currency/Importer/CzechNationalBankImporter.php b/src/Sylius/Component/Currency/Importer/CzechNationalBankImporter.php new file mode 100644 index 00000000000..fa4c17eb52a --- /dev/null +++ b/src/Sylius/Component/Currency/Importer/CzechNationalBankImporter.php @@ -0,0 +1,50 @@ +url . $date->format('d.m.Y'); + + $xml = @simplexml_load_file($fullUrl); + + if ($xml instanceof \SimpleXMLElement) { + + $data = $xml->xpath('/kurzy/tabulka/*'); + + foreach ($data as $row) { + + $currency = (string)$row->attributes()->kod; + + $rate = str_replace(',', '.', $row->attributes()->kurz); + $ammount = (int)$row->attributes()->mnozstvi; + $rateToCZK = floatval($ammount/$rate); + + echo ($ammount/$ammount) . ' ' . 'CZK' . ' == ' . $rateToCZK . ' ' . $currency . "\n"; + + $this->updateOrCreate($managedCurrencies, (string) $currency, $rateToCZK); + } + + $this->manager->flush(); + } + } +}