Your server configuration may be blocking PrestaShop's call to the currency XML feed. You'll need to contact your host and ask them to unblock it.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.
It is http://www.prestasho...currencies.xml. If PrestaShop can't access that file, then it can't update the currency rates.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.
So that file is on Pretashop.com server?, wher/ in witsh file in my shop is the link to the file supose to be?
The file isn't in your shop. It is read directly from the PrestaShop server. That's why it isn't working for you. Your server configuration isn't letting PrestaShop read it off the server.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.
OK, i'v asked my server company to look at this.
I found this code in \Classes\currency.php
static public function refreshCurrencies()
{
if (!$feed = @simplexml_load_file('http://www.prestashop.com/xml/currencies.xml'))
return Tools::displayError('Cannot parse feed!');
if (!$defaultCurrency = intval(Configuration::get('PS_CURRENCY_DEFAULT')))
return Tools::displayError('No default currency!');
$isoCodeSource = strval($feed->source['iso_code']);
$currencies = self::getCurrencies(true);
$defaultCurrency = self::refreshCurrenciesGetDefault($feed->list, $isoCodeSource, $defaultCurrency);
foreach ($currencies as $currency)
if ($currency->iso_code != $defaultCurrency->iso_code)
$currency->refreshCurrency($feed->list, $isoCodeSource, $defaultCurrency);
}
}
?>
Does ths look right, can you compare whit your file? is this file supose to be 777?
I found this code in \Classes\currency.php
static public function refreshCurrencies()
{
if (!$feed = @simplexml_load_file('http://www.prestashop.com/xml/currencies.xml'))
return Tools::displayError('Cannot parse feed!');
if (!$defaultCurrency = intval(Configuration::get('PS_CURRENCY_DEFAULT')))
return Tools::displayError('No default currency!');
$isoCodeSource = strval($feed->source['iso_code']);
$currencies = self::getCurrencies(true);
$defaultCurrency = self::refreshCurrenciesGetDefault($feed->list, $isoCodeSource, $defaultCurrency);
foreach ($currencies as $currency)
if ($currency->iso_code != $defaultCurrency->iso_code)
$currency->refreshCurrency($feed->list, $isoCodeSource, $defaultCurrency);
}
}
?>
Does ths look right, can you compare whit your file? is this file supose to be 777?
That's the same as my file. The problem is that your server is returning false when @simplexml_load_file('http://www.prestashop.com/xml/currencies.xml') in executed, whereas it is returning the feed on my server.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.
No, classes/Currency.php does not need to be chmod 777, and you can't change the permissions on the currencies.xml file since it is on PrestaShop's server.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.
I get a question from my server admin, (What is required for the service to work? In what way is the XML feeds retrieved through "PrestaShop"?
What do i answer. Can i show them the classes/currency.php file?
What do i answer. Can i show them the classes/currency.php file?
Just ask them whether your server is configured to allow @simplexml_load_file('http://www.prestashop.com/xml/currencies.xml') to work.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.
The server admin replayed this:
Seems as if this is fopen, which is not permitted on our servers. Tip is that you us a curl script to first get home this locally and then see if it works to read it.
Seems as if this is fopen, which is not permitted on our servers. Tip is that you us a curl script to first get home this locally and then see if it works to read it.
It looks like you'll need to change to a server that uses fopen or rewrite PrestaShop's code to use cURL. I did a Google search and found this site which has cURL code. You could try using code similar to it. Unfortunately, I'm not familiar with cURL, so I can't help any more.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.
OK i got a file from the server admin, this is the kode: see img.
i wright http://www.prestasho.../currencies.xml - insted of http://www.loopia.se/ - But wher do i put in the serchway/link to this file?
The filename is: file_get_url_contents.php
Do you think this will work?
i wright http://www.prestasho.../currencies.xml - insted of http://www.loopia.se/ - But wher do i put in the serchway/link to this file?
The filename is: file_get_url_contents.php
Do you think this will work?
Attached Files
Yes, that should work. Use that code to get the currencies.xml file as a string, then use the following code to read the string into XML:
$feed = @simplexml_load_string($res);
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.
OK, so do iput in the code i got from server admin in to classes/Currency.php insted of http://www.prestasho...currencies.xml. and den insert the code to read the string into XML after that code?
Replace the refreshCurrencies() function on lines 217-229 of classes/Currency.php (in PrestaShop v1.3):
with the following two functions:
static public function refreshCurrencies()
{
if (!$feed = @simplexml_load_file('http://www.prestashop.com/xml/currencies.xml'))
return Tools::displayError('Cannot parse feed!');
if (!$defaultCurrency = intval(Configuration::get('PS_CURRENCY_DEFAULT')))
return Tools::displayError('No default currency!');
$isoCodeSource = strval($feed->source['iso_code']);
$currencies = self::getCurrencies(true);
$defaultCurrency = self::refreshCurrenciesGetDefault($feed->list, $isoCodeSource, $defaultCurrency);
foreach ($currencies as $currency)
if ($currency->iso_code != $defaultCurrency->iso_code)
$currency->refreshCurrency($feed->list, $isoCodeSource, $defaultCurrency);
}
with the following two functions:
static public function file_get_url_contents($url) {
if (preg_match('/^([a-z]+):\/\/([a-z0-9-.]+)(\/.*$)/i', $url, $matches)) {
$protocol = strtolower($matches[1]);
$host = $matches[2];
$path = $matches[3];
} else {
// Bad url-format
return FALSE;
}
if ($protocol == "http") {
$socket = fsockopen($host, 80);
} else {
// Bad protocol
return FALSE;
}
if (!socket) {
// Error creating socket
return FALSE;
}
$request = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
$len_written = fwrite($socket, $request);
if ($len_written === FALSE || $len_written != strlen($request)) {
// Error sending request
return FALSE;
}
$response = "";
while (!feof($socket) && ($buf = fread($socket, 4096)) !== FALSE) {
$response .= $buf;
}
if ($buf === FALSE) {
// Error reading response
return FALSE;
}
$end_of_header = strpos($response, "\r\n\r\n");
return substr($response, $end_of_header + 4);
}
static public function refreshCurrencies()
{
$url = "http://www.prestashop.com/xml/currencies.xml";
$res = self::file_get_url_contents($url);
if ($res === FALSE)
return Tools::displayError("Error fetching $url");
else
{
if (!$feed = @simplexml_load_string($res))
return Tools::displayError('Cannot parse feed!');
if (!$defaultCurrency = intval(Configuration::get('PS_CURRENCY_DEFAULT')))
return Tools::displayError('No default currency!');
$isoCodeSource = strval($feed->source['iso_code']);
$currencies = self::getCurrencies(true);
$defaultCurrency = self::refreshCurrenciesGetDefault($feed->list, $isoCodeSource, $defaultCurrency);
foreach ($currencies as $currency)
if ($currency->iso_code != $defaultCurrency->iso_code)
$currency->refreshCurrency($feed->list, $isoCodeSource, $defaultCurrency);
}
}
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.




Back to top










