use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\Locale\CurrencyInterface;
protected $storeManager;
protected $localeCurrency;
public function __construct(
...
StoreManagerInterface $storeManager,
CurrencyInterface $localeCurrency
....
) {
....
$this->storeManager = $storeManager;
$this->localeCurrency = $localeCurrency;
....
}
$currencyCodes=$this->storeManager->getStore(1)->getAvailableCurrencyCodes(); // replace with your store Id
if($currencyCodes){
foreach ($currencyCodes as $code){
$currencyData[$code]=$this->localeCurrency->getCurrency($code)->getName();
}
print_r($currencyData);exit;
}
I know foreach
loop is bad to prepare array but I think there is no direct method available to get the currency name, even Magento team does the forech
loop to print the currency name. You can also confirm this in
app\code\Magento\Sales\view\adminhtml\templates\order\create\data.phtml