I have 2 websites in my magento. I have created one custom extension. In custom extension, i have form to fill which have firstname , last name, product price, store id.
Website 1 currency = USD (Deafult currency) Website 2 currency = EUR
When i submit form data will be saved in custom table and shown in custom admin grid. I want to show price according to the store wise entry.
If i fill form website 1 then my price needs to show like $54.00 and if i fill form from website 2 then price needs to show like €10.00.
I have used below code to show formatted price with currency in admin.
<?php
namespace Vendor\Extension\Block;
class Customprice extends \Magento\Framework\View\Element\Template
{
protected $priceCurrency;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
array $data = []
) {
$this->priceCurrency = $priceCurrency;
parent::__construct($context, $data);
}
public function getCurrencyWithFormat($price)
{
return $this->priceCurrency->format($price,true,2);
}
}
In website 2 if $price = 10; then according to above code it will be shown like $10.00 but in website 2 it should show like €10.00.
$formmattedPrice = $this->getCurrencyWithFormat($price);
I am facing problem only in admin. In front end it shows proper currency according to store wise.