Jump to content

Update currency rates from another bank (not Europian Central Bank)


Recommended Posts

Well i gues i have to change this function in classes/Currency.php:

 

To answer my own question :D, first i have to add cron that will generate http://mydomain.com/xml/currencies.xml from whatever bank i want and after that i need to change function to point and parse my newly generated XML.

    public static function refreshCurrencies()
    {
        // Parse
        //if (!$feed = Tools::simplexml_load_file('http://api.prestashop.com/xml/currencies.xml'))
        if (!$feed = Tools::simplexml_load_file('http://mydomain.com/xml/currencies.xml'))
            return Tools::displayError('Cannot parse feed.');

        // Default feed currency (EUR)
        $isoCodeSource = strval($feed->source['iso_code']);

        if (!$default_currency = Currency::getDefaultCurrency())
            return Tools::displayError('No default currency');

        $currencies = Currency::getCurrencies(true, false);
        foreach ($currencies as $currency)
            if ($currency->id != $default_currency->id)
                $currency->refreshCurrency($feed->list, $isoCodeSource, $default_currency);
    }

Just an idea. Needs to be tested :D

Edited by prestamin (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...