-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' into improve-graphql-stitching-perf
- Loading branch information
Showing
2,490 changed files
with
159,102 additions
and
91,857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
app/code/Magento/AdvancedPricingImportExport/Model/CurrencyResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\AdvancedPricingImportExport\Model; | ||
|
||
use Magento\Directory\Helper\Data as DirectoryData; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
/** | ||
* Currency resolver for tier price scope | ||
*/ | ||
class CurrencyResolver | ||
{ | ||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* @var DirectoryData | ||
*/ | ||
private $directoryData; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $defaultBaseCurrency; | ||
|
||
/** | ||
* Associative array with website code as the key and base currency as the value | ||
* | ||
* @var array | ||
*/ | ||
private $websitesBaseCurrency; | ||
|
||
/** | ||
* @param StoreManagerInterface $storeManager | ||
* @param DirectoryData $directoryData | ||
*/ | ||
public function __construct( | ||
StoreManagerInterface $storeManager, | ||
DirectoryData $directoryData | ||
) { | ||
$this->storeManager = $storeManager; | ||
$this->directoryData = $directoryData; | ||
} | ||
|
||
/** | ||
* Get base currency for all websites | ||
* | ||
* @return array associative array with website code as the key and base currency as the value | ||
*/ | ||
public function getWebsitesBaseCurrency(): array | ||
{ | ||
if ($this->websitesBaseCurrency === null) { | ||
$this->websitesBaseCurrency = []; | ||
foreach ($this->storeManager->getWebsites() as $website) { | ||
$this->websitesBaseCurrency[$website->getCode()] = $website->getBaseCurrencyCode(); | ||
} | ||
} | ||
|
||
return $this->websitesBaseCurrency; | ||
} | ||
|
||
/** | ||
* Get default scope base currency | ||
* | ||
* @return string | ||
*/ | ||
public function getDefaultBaseCurrency(): string | ||
{ | ||
if ($this->defaultBaseCurrency === null) { | ||
$this->defaultBaseCurrency = $this->directoryData->getBaseCurrencyCode(); | ||
} | ||
|
||
return $this->defaultBaseCurrency; | ||
} | ||
} |
Oops, something went wrong.