Skip to content

Commit

Permalink
Merge pull request #472 from magento-api/develop
Browse files Browse the repository at this point in the history
[API] Bug Fixes 39919, 39700
  • Loading branch information
vpelipenko committed Jul 15, 2015
2 parents 0b8fc26 + 5cf055f commit 3bd64f6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
38 changes: 34 additions & 4 deletions app/code/Magento/Config/Model/Config/Backend/Currency/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/**
* Backend Directory currency backend model
* Allows dispatching before and after events for each controller action
Expand All @@ -14,6 +12,33 @@

class Base extends AbstractCurrency
{
/** @var \Magento\Directory\Model\CurrencyFactory */
private $currencyFactory;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct($context, $registry, $config, $scopeConfig, $resource, $resourceCollection, $data);
$this->currencyFactory = $currencyFactory;
}

/**
* Check base currency is available in installed currencies
*
Expand All @@ -22,9 +47,14 @@ class Base extends AbstractCurrency
*/
public function afterSave()
{
if (!in_array($this->getValue(), $this->_getInstalledCurrencies())) {
throw new \Magento\Framework\Exception\LocalizedException(__('Sorry, we haven\'t installed the base currency you selected.'));
$value = $this->getValue();
if (!in_array($value, $this->_getInstalledCurrencies())) {
throw new \Magento\Framework\Exception\LocalizedException(
__('Sorry, we haven\'t installed the base currency you selected.')
);
}

$this->currencyFactory->create()->saveRates([$value =>[$value => 1]]);
return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __construct()
$objectManager = Bootstrap::getObjectManager();
$this->_soapConfig = $objectManager->get('Magento\Webapi\Model\Soap\Config');
$this->_converter = $objectManager->get('Magento\Framework\Api\SimpleDataObjectConverter');
ini_set('default_socket_timeout', 120);
}

/**
Expand Down
3 changes: 0 additions & 3 deletions lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -1801,9 +1801,6 @@ public function insertOnDuplicate($table, array $data, array $fields = [])
$fields = $cols;
}

// quote column names
// $cols = array_map(array($this, 'quoteIdentifier'), $cols);

// prepare ON DUPLICATE KEY conditions
foreach ($fields as $k => $v) {
$field = $value = null;
Expand Down

0 comments on commit 3bd64f6

Please sign in to comment.