-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: ConfigFixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 releasebug report
Description
Checking Use system value for the base currency in the currency options results in a configuration error when importing currency rates.
Preconditions
- Magento CE v2.1.3
- PHP v7.0.14
- MySQL v14.14 Distrib 5.7.16, for osx 10.12
Steps to reproduce
- Log into Admin
- Navigate to
Stores > Settings > Configuration > General > Currency Setup - Select
Use system valueforBase Currency - Select
YesforEnabledin theScheduled Import Settingssection - Click
Save Configif necessary and flush the cache - Navigate to
Stores > Currency > Currency Rates - Try Importing Currency Rates via any of the three services
Expected result
- Currency rates are imported for
Allowed Currencies
Actual result
You must first configure currency options before being able to see currency rates.is displayed onCurrency Ratespage and user is unable to import rates via any of the services.
Additional Notes
I was able to work around this issue by unselecting Use system value and explicitly selecting a Base Currency.
This issue seems to be a result of the base currency not being written to the database when Use system value is selected
mysql> mysql> select * from core_config_data where path='currency/options/base';
Empty set (0.00 sec)
This results in this method failing to fetch the rates as $defaultCurrencies (actually base currencies) is empty:
<magento install dir>/vendor/magento/module-directory/Model/Currency/Import/AbstractImport.php#L92-L117
/**
* @return array
*/
public function fetchRates()
{
$data = [];
$currencies = $this->_getCurrencyCodes();
$defaultCurrencies = $this->_getDefaultCurrencyCodes();
set_time_limit(0);
foreach ($defaultCurrencies as $currencyFrom) {
if (!isset($data[$currencyFrom])) {
$data[$currencyFrom] = [];
}
foreach ($currencies as $currencyTo) {
if ($currencyFrom == $currencyTo) {
$data[$currencyFrom][$currencyTo] = $this->_numberFormat(1);
} else {
$data[$currencyFrom][$currencyTo] = $this->_numberFormat(
$this->_convert($currencyFrom, $currencyTo)
);
}
}
ksort($data[$currencyFrom]);
}
ini_restore('max_execution_time');
return $data;
}
Also, the _getDefaultCurrencyCodes() method is getting the base currencies rather than the default currencies, which may be a bug or just a poor naming choice:
<magento install dir>/vendor/magento/module-directory/Model/Currency/Import/AbstractImport.php#L49-L52
protected function _getDefaultCurrencyCodes()
{
return $this->_currencyFactory->create()->getConfigBaseCurrencies();
}
mmenozzi, dmanners and flancer64
Metadata
Metadata
Assignees
Labels
Component: ConfigFixed in 2.2.xThe issue has been fixed in 2.2 release lineThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 releasebug report

