I have a problem with currency convert, my base currency is Indian Rupee and i mapped Indian Rupee and [USD] to the site. Currency rates also given correctly. While i changed INR to USD its showing wrong prices in the site at category page and product page, in check out page its showing correct value. Thank you
Magento – Regarding currency conversion error INR and USD
convertcurrencymagento-1.8multicurrency
Related Solutions
Here is something that should convert the prices.
I know it's not the best way of doing it by touching the db directly, but it's fast and it works.
Please back-up your db before trying any of this.
So all price related values are kept in the table catalog_product_entity_decimal
and catalog_product_entity_tier_price
in case you have tier prices.
For tier prices is simple.
Just update the value of the column value
with the converted value.
So today the conversion rate for 1E is 4.4193 RON.
Run this query:
UPDATE `catalog_product_entity_tier_price` set `value ` = 4.4193 * `value`;
This should solve it.
For the rest of the prices is not that easy.
First you need to identify the attribute ids for price
and special_price
.
For that run this query.
SELECT
*
FROM
`eav_attribute` e
LEFT JOIN `eav_entity_type` et ON `e`.`entity_type_id` = `et`.`entity_type_id`
WHERE
`e`.`attribute_code` IN ('price', 'special_price') AND
`et`.`entity_type_code` = 'catalog_product'
This should produce 2 rows. Take the column attribute_id
values and use them in the query below. For me these values were 75
and 76
.
Now run this query for updating the prices.
UPDATE
`catalog_product_entity_decimal`
SET
`value` = 4.4193 * `value`
WHERE
`attribute_id` IN (75, 76)
Again 4.4193
is the exchange rate.
Now you can set your base currency to RON. Clear the cache and reindex everything.
When you feel like 'the calculation is wrong', it always helps to look at the source code. When I look at \Magento\Directory\Model\Currency::convert()
(this is the inner method that \Magento\Directory\Helper\Data::currencyConvert()
uses), I see something interesting:
public function convert($price, $toCurrency = null)
{
if ($toCurrency === null) {
return $price;
} elseif ($rate = $this->getRate($toCurrency)) {
return $price * $rate;
}
This means that it converts the price to the rate that is set in the $toCurrency
. In your example your convert EUR to USD. I guess the rate of USD is 1.00, so when you're converting 14 USD * 1.00, you get 13.99 (I guess this is due to how floating numbers work?).
How to solve this? Well, you have your base price in USD, and you know that EUR has a rate of 0.75, so if you have code that fetches the base price of your product, loads the EUR rate and multiplies it with that you might be set to go. For example:
$basePrice = $product->getPrice();
$currency = $currencyFactory->create()->load('EUR');
$eurPrice = $currency->convert($basePrice, 'EUR');
Haven't tested it yet so I'm not sure if it works, only following the code. But perhaps it helps you finding your solution.
Best Answer
Magento currency rates is manged from admin, so to
admin > system >Manage Currency >Rates
and managed currency symbol from
admin > system >Manage Currency >Symbols
If want to add multiple currency then
goto admin > system > GENERAL > Currency setup> Allowed Currencies
.More details:http://www.amitbera.com/get-currency-rates-for-a-multiple-currencies-in-magento/#sthash.471ye9oH.dpuf
I thought, you have not converting price whenever you have called product price statis.