forked from Hevelop/magento2-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Patch-Magento_Directory-M2.1.11-update-fixerio-api-endpoint-and-add-accesskey-configuration.patch
38 lines (35 loc) · 1.78 KB
/
Patch-Magento_Directory-M2.1.11-update-fixerio-api-endpoint-and-add-accesskey-configuration.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--- Model/Currency/Import/FixerIo.php (date 1539769041000)
+++ Model/Currency/Import/FixerIo.php (date 1539769185000)
@@ -13,7 +13,7 @@
/**
* @var string
*/
- const CURRENCY_CONVERTER_URL = 'http://api.fixer.io/latest?base={{CURRENCY_FROM}}&symbols={{CURRENCY_TO}}';
+ const CURRENCY_CONVERTER_URL = 'http://api.fixer.io/live?currencies={{CURRENCY_TO}}';
/**
* Http Client Factory
@@ -78,6 +78,8 @@
$currenciesStr = implode(',', $currenciesTo);
$url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, self::CURRENCY_CONVERTER_URL);
$url = str_replace('{{CURRENCY_TO}}', $currenciesStr, $url);
+ $fixerAccessKey = $this->scopeConfig->getValue('currency/fixerio/access_key');
+ $url = str_replace('http://api.fixer.io/', 'http://data.fixer.io/api/', $url . "&access_key=" . $fixerAccessKey);
set_time_limit(0);
try {
@@ -90,12 +92,12 @@
if ($currencyFrom == $currencyTo) {
$data[$currencyFrom][$currencyTo] = $this->_numberFormat(1);
} else {
- if (empty($response['rates'][$currencyTo])) {
+ if (empty($response['quotes']['USD' . $currencyTo]) || empty($response['quotes']['USD' . $currencyFrom])) {
$this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $url, $currencyTo);
$data[$currencyFrom][$currencyTo] = null;
} else {
$data[$currencyFrom][$currencyTo] = $this->_numberFormat(
- (double)$response['rates'][$currencyTo]
+ (double)($response['quotes']['USD' . $currencyTo] / $response['quotes']['USD' . $currencyFrom])
);
}
}
--
magento/module-directory 100.2.5