Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using System Value for Base Currency Results in Config Error #8003

Closed
tsmith1985 opened this issue Dec 30, 2016 · 6 comments
Closed

Using System Value for Base Currency Results in Config Error #8003

tsmith1985 opened this issue Dec 30, 2016 · 6 comments
Assignees
Labels
bug report Component: Config Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@tsmith1985
Copy link

tsmith1985 commented Dec 30, 2016

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

  1. Log into Admin
  2. Navigate to Stores > Settings > Configuration > General > Currency Setup
  3. Select Use system value for Base Currency
  4. Select Yes for Enabled in the Scheduled Import Settings section
  5. Click Save Config if necessary and flush the cache
  6. Navigate to Stores > Currency > Currency Rates
  7. Try Importing Currency Rates via any of the three services

Expected result

  1. Currency rates are imported for Allowed Currencies

Actual result

  1. You must first configure currency options before being able to see currency rates. is displayed on Currency Rates page and user is unable to import rates via any of the services.

currency_options

currency_rates

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();
}

@veloraven
Copy link
Contributor

@tsmith1985 thank you for your report.
We have created internal ticket MAGETWO-62921

@veloraven veloraven added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jan 4, 2017
@michael-tourneur
Copy link

@veloraven this issue has been fixed and merged?

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Config Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@tsmith1985, thank you for your report.
We've created internal ticket(s) MAGETWO-62921 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@nmalevanec nmalevanec self-assigned this Oct 26, 2017
@okorshenko
Copy link
Contributor

The issue has neeb fixed and delivered to 2.2-develop branch

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Nov 21, 2017
@magento-engcom-team
Copy link
Contributor

Hi @tsmith1985. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1358 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Feb 8, 2018
@harshvardhanmalpani
Copy link

This issue is still present in 2.2.4. None of exchange rate providers work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Config Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

7 participants