Change Magento Base and Display Currency and Auto-Update Prices (EUR to RON)

currencycurrency-ratesmulticurrency

I have an old Magento ecommerce site, with about 400 products. Initially, it was made to be in EURO, both in the backend, and the frontend. I need to fully migrate it to the local currency. Here is what I've done for now: I set the BASE currency to EUR (as it was), and the display currency to RON (Romanian Leu, local currency). And I set a base exchange rate, and then set it to update daily from WebserviceX. This solved half of my problem. When a user enters, he is presented the site in the local currency, with the option to switch to EUR in topbar. But my problem is that when I add new products, is asks me in EUR. I somehow need to set the BASE currency as the local RON. But if I set it to RON, the prices do not update! — A product that is 500EUR, when base is set to eur and display to ron, displays as 2300RON, which is correct. When both the base and the display are in RON, a 500EUR product displays as 500RON, the conversion does not work if I set RON as base. I need to convert the prices in back-end automatically from EUR -> , so that than I can set base to RON and have them entered by default in RON from now on. How can I do that? I can't manually update 400 products.

Best Answer

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.

Related Topic