44 \
Magento\Directory\Model\CurrencyFactory $currencyFactory,
45 \
Magento\Framework\
Data\Helper\PostHelper $postDataHelper,
49 $this->_currencyFactory = $currencyFactory;
50 $this->_postDataHelper = $postDataHelper;
51 parent::__construct($context,
$data);
75 $currencies = $this->
getData(
'currencies');
76 if ($currencies ===
null) {
78 $codes = $this->_storeManager->getStore()->getAvailableCurrencyCodes(
true);
79 if (is_array($codes) && count($codes) > 1) {
80 $rates = $this->_currencyFactory->create()->getCurrencyRates(
81 $this->_storeManager->getStore()->getBaseCurrency(),
85 foreach ($codes as
$code) {
87 $allCurrencies = (
new CurrencyBundle())->
get(
88 $this->localeResolver->getLocale()
95 $this->
setData(
'currencies', $currencies);
107 return $this->
getUrl(
'directory/currency/switch');
128 if ($this->
_getData(
'current_currency_code') ===
null) {
131 $this->
setData(
'current_currency_code', $this->_storeManager->getStore()->getCurrentCurrency()->getCode());
133 return $this->
_getData(
'current_currency_code');
141 return $this->_storeManager->getStore()->getCode();
getData($key='', $index=null)
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Data\Helper\PostHelper $postDataHelper, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data=[])
getUrl($route='', $params=[])
getSwitchCurrencyPostData($code)
setData($key, $value=null)