0

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.

1

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.

  • Should this work on any version? Haven't updated in about 6 months and not going to do it now. xD Anyway, thank you very much! Spent some time looking for this. – Bodo Jul 14 '14 at 12:02
  • @Bodo It should work on any version. The way the prices are kept hasn't changed much. Just some indexes have changed but don't need to worry about this because the indexing will be done by Magento the way it knows. :) – Marius Jul 14 '14 at 12:03
  • So if I don't have tier prices, only one price per product, I only need to execute this one: UPDATE catalog_product_entity_tier_price set value = 4.4193 * value; ? – Bodo Jul 14 '14 at 12:06
  • @Bodo. Nope. The other way around. If you don't have tier prices skip the one you mentioned and run the rest. – Marius Jul 14 '14 at 12:08
  • (off-topic: was not expecting an answer from a Romanian guy. There aren't many of us on the stack network. Or I just didn't find :)) ) Ok got it. I don't have tier prices, but some products have set a "Special price". The discount is applied 'by hand'. (subtracted from the original price, not with a percent or something). Probably that's a different row, that needs different code execution? Am I right? – Bodo Jul 14 '14 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.