diff --git a/src/Sylius/Component/Currency/Importer/AbstractImporter.php b/src/Sylius/Component/Currency/Importer/AbstractImporter.php index 3c0e6e88e4e..ae32cb4ad76 100644 --- a/src/Sylius/Component/Currency/Importer/AbstractImporter.php +++ b/src/Sylius/Component/Currency/Importer/AbstractImporter.php @@ -44,23 +44,22 @@ public function __construct(ObjectManager $manager, RepositoryInterface $reposit */ protected function updateOrCreate(array $managedCurrencies, $code, $rate) { - if (!empty($managedCurrencies) && !in_array($code, $managedCurrencies)) { - foreach ($managedCurrencies as $currency) { - if ($code === $currency->getCode()) { - $currency->setExchangeRate($rate); - - $this->manager->persist($currency); - - return; - } + foreach ($managedCurrencies as $currency) { + if ($code === $currency->getCode()) { + $currency->setExchangeRate($rate); + $this->manager->persist($currency); + return; } - } else { - /** @var $currency CurrencyInterface */ - $currency = $this->repository->createNew(); - $currency->setCode($code); - $currency->setExchangeRate($rate); + } - $this->manager->persist($currency); + if (!empty($managedCurrencies)) { + return; } + + /** @var $currency CurrencyInterface */ + $currency = $this->repository->createNew(); + $currency->setCode($code); + $currency->setExchangeRate($rate); + $this->manager->persist($currency); } }