Skip to content

Commit 9a1941a

Browse files
author
Dale Sikkema
committed
MAGETWO-39919: Not All allowed Currencies displayed on switcher if base currency !=USD
- after base currency is saved, save the conversion rate to itself of '1'
1 parent ec6d4e6 commit 9a1941a

File tree

2 files changed

+30
-4
lines changed
  • app/code/Magento/Config/Model/Config/Backend/Currency
  • lib/internal/Magento/Framework/DB/Adapter/Pdo

2 files changed

+30
-4
lines changed

app/code/Magento/Config/Model/Config/Backend/Currency/Base.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@
1414

1515
class Base extends AbstractCurrency
1616
{
17+
/** @var \Magento\Directory\Model\Currency */
18+
private $currency;
19+
20+
/**
21+
* @param \Magento\Framework\Model\Context $context
22+
* @param \Magento\Framework\Registry $registry
23+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
24+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
25+
* @param \Magento\Directory\Model\Currency $currency
26+
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
27+
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
28+
* @param array $data
29+
*/
30+
public function __construct(
31+
\Magento\Framework\Model\Context $context,
32+
\Magento\Framework\Registry $registry,
33+
\Magento\Framework\App\Config\ScopeConfigInterface $config,
34+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
35+
\Magento\Directory\Model\Currency $currency,
36+
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
37+
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
38+
array $data = []
39+
) {
40+
parent::__construct($context, $registry, $config, $scopeConfig, $resource, $resourceCollection, $data);
41+
$this->currency = $currency;
42+
}
1743
/**
1844
* Check base currency is available in installed currencies
1945
*
@@ -22,9 +48,12 @@ class Base extends AbstractCurrency
2248
*/
2349
public function afterSave()
2450
{
25-
if (!in_array($this->getValue(), $this->_getInstalledCurrencies())) {
51+
$value = $this->getValue();
52+
if (!in_array($value, $this->_getInstalledCurrencies())) {
2653
throw new \Magento\Framework\Exception\LocalizedException(__('Sorry, we haven\'t installed the base currency you selected.'));
2754
}
55+
56+
$this->currency->saveRates([$value =>[$value => 1]]);
2857
return $this;
2958
}
3059
}

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,9 +1801,6 @@ public function insertOnDuplicate($table, array $data, array $fields = [])
18011801
$fields = $cols;
18021802
}
18031803

1804-
// quote column names
1805-
// $cols = array_map(array($this, 'quoteIdentifier'), $cols);
1806-
18071804
// prepare ON DUPLICATE KEY conditions
18081805
foreach ($fields as $k => $v) {
18091806
$field = $value = null;

0 commit comments

Comments
 (0)