Skip to content

Commit 0d68585

Browse files
author
Cari Spruiell
committed
Merge remote-tracking branch 'remotes/api/MAGETWO-39919-currency-switcher' into develop
2 parents cabd186 + 4056769 commit 0d68585

File tree

2 files changed

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

2 files changed

+34
-7
lines changed

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

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
/**
108
* Backend Directory currency backend model
119
* Allows dispatching before and after events for each controller action
@@ -14,6 +12,33 @@
1412

1513
class Base extends AbstractCurrency
1614
{
15+
/** @var \Magento\Directory\Model\CurrencyFactory */
16+
private $currencyFactory;
17+
18+
/**
19+
* @param \Magento\Framework\Model\Context $context
20+
* @param \Magento\Framework\Registry $registry
21+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
22+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
23+
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
24+
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
25+
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
26+
* @param array $data
27+
*/
28+
public function __construct(
29+
\Magento\Framework\Model\Context $context,
30+
\Magento\Framework\Registry $registry,
31+
\Magento\Framework\App\Config\ScopeConfigInterface $config,
32+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
33+
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
34+
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
35+
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
36+
array $data = []
37+
) {
38+
parent::__construct($context, $registry, $config, $scopeConfig, $resource, $resourceCollection, $data);
39+
$this->currencyFactory = $currencyFactory;
40+
}
41+
1742
/**
1843
* Check base currency is available in installed currencies
1944
*
@@ -22,9 +47,14 @@ class Base extends AbstractCurrency
2247
*/
2348
public function afterSave()
2449
{
25-
if (!in_array($this->getValue(), $this->_getInstalledCurrencies())) {
26-
throw new \Magento\Framework\Exception\LocalizedException(__('Sorry, we haven\'t installed the base currency you selected.'));
50+
$value = $this->getValue();
51+
if (!in_array($value, $this->_getInstalledCurrencies())) {
52+
throw new \Magento\Framework\Exception\LocalizedException(
53+
__('Sorry, we haven\'t installed the base currency you selected.')
54+
);
2755
}
56+
57+
$this->currencyFactory->create()->saveRates([$value =>[$value => 1]]);
2858
return $this;
2959
}
3060
}

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)