|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +// phpcs:ignore Magento2.Security.IncludeFile |
| 9 | +require_once __DIR__ . '/second_store.php'; |
| 10 | + |
| 11 | +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
| 12 | +$store = $objectManager->create(\Magento\Store\Model\Store::class); |
| 13 | +if ($storeId = $store->load('fixture_second_store', 'code')->getId()) { |
| 14 | + /** @var \Magento\Config\Model\ResourceModel\Config $configResource */ |
| 15 | + $configResource = $objectManager->get(\Magento\Config\Model\ResourceModel\Config::class); |
| 16 | + $configResource->saveConfig( |
| 17 | + \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_DEFAULT, |
| 18 | + 'EUR', |
| 19 | + \Magento\Store\Model\ScopeInterface::SCOPE_STORES, |
| 20 | + $storeId |
| 21 | + ); |
| 22 | + $configResource->saveConfig( |
| 23 | + \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW, |
| 24 | + 'EUR', |
| 25 | + \Magento\Store\Model\ScopeInterface::SCOPE_STORES, |
| 26 | + $storeId |
| 27 | + ); |
| 28 | + /** |
| 29 | + * Configuration cache clean is required to reload currency setting |
| 30 | + */ |
| 31 | + /** @var Magento\Config\App\Config\Type\System $config */ |
| 32 | + $config = $objectManager->get(\Magento\Config\App\Config\Type\System::class); |
| 33 | + $config->clean(); |
| 34 | +} |
| 35 | + |
| 36 | + |
| 37 | +/** @var \Magento\Directory\Model\ResourceModel\Currency $rate */ |
| 38 | +$rate = $objectManager->create(\Magento\Directory\Model\ResourceModel\Currency::class); |
| 39 | +$rate->saveRates( |
| 40 | + [ |
| 41 | + 'USD' => ['EUR' => 2], |
| 42 | + 'EUR' => ['USD' => 0.5] |
| 43 | + ] |
| 44 | +); |
0 commit comments