Edit: I see someone beat me to it! Great minds think alike I guess. In the end, I got tired of waiting and fixed the problem myself. I'm sharing the code here in case anyone finds it useful. The code below works for me, but I make no guarantees. Use it at your own risk. I'm using rates from the European Central Bank ( http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml ). It doesn't contain as many rates as the original Prestashop version, but it has enough to suit my purposes. If you'd like to use this, create a file called "Currency.php" and place it in the "/override/classes/" directory. If you use "cron_currency_update", it will call the method in this file instead. class Currency extends CurrencyCore { /** * Refresh the currency exchange rate * The XML file define exchange rate for each from a default currency ($isoCodeSource). * * @param SimpleXMLElement $data XML content which contains all the exchange rates * @param string $isoCodeSource The default currency used in the XML file * @param Currency $defaultCurrency The default currency object */ public function refreshCurrency($data, $isoCodeSource, $defaultCurrency) { // fetch the exchange rate of the default currency $exchange_rate = 1; $tmp = $this->conversion_rate; if ($defaultCurrency->iso_code != $isoCodeSource) { foreach ($data->Cube as $currency) { if ($currency['currency'] == $defaultCurrency->iso_code) { $exchange_rate = round((float)$currency['rate'], 6); break; } } } if ($defaultCurrency->iso_code == $this->iso_code) { $this->conversion_rate = 1; } else { if ($this->iso_code == $isoCodeSource) { $rate = 1; } else { foreach ($data->Cube as $obj) { if ($this->iso_code == strval($obj['currency'])) { $rate = (float)$obj['rate']; break; } } } if (isset($rate)) { $this->conversion_rate = round($rate / $exchange_rate, 6); } } if ($tmp != $this->conversion_rate) { $this->update(); } } public static function refreshCurrencies() { // Prestashop no longer provide currency rates from their API // get them from the European Central Bank if (!$feed = Tools::simplexml_load_file('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml')) { return Tools::displayError('Cannot parse feed.'); } // Default feed currency - this is always EUR and not provided in the feed: hardcode it $isoCodeSource = 'EUR'; // returns the shop default - we want this to be EUR //if (!$default_currency = Currency::getDefaultCurrency()) { $default_currency_id = Currency::getIdByIsoCode($isoCodeSource); if (!$default_currency = Currency::getCurrency($default_currency_id)) { return Tools::displayError('No default currency');
}
$currencies = Currency::getCurrencies(true, false, true); foreach ($currencies as $currency) { /** @var Currency $currency */ if ($currency->id != $default_currency->id) { // in our xml, the rates are nested in two "Cube" elements if ( isset($feed->Cube, $feed->Cube->Cube) ) $currency->refreshCurrency($feed->Cube->Cube, $isoCodeSource, $default_currency); } } } }