3

I am trying to set format of currency for a country with impex. Currentlty it is set as '42,953.87'. I want it should be changed to the format as '42.953,87'. Right now impex I am using for it is as

INSERT_UPDATE Currency;isocode[unique=true];conversion;digits;symbol
;ABC;1;2;kr

What changes I need to make in above impex code to make it in format as 24.953,87 I tried ;ABC;;;2;kr but it does not work.Is there any other way in hybris through which I can change currency format?

Naved Ali
  • 616
  • 1
  • 14
  • 31
  • I think you need custom locale for java also. because formatting made by java locale. – mkysoft Jun 30 '17 at 18:51
  • @mkysoft I tried to change locale with code UPDATE CMSSite;uid[unique=true];locale[lang=en] ;electronics;sv_SE, but in that case It is also affecting other things. Like Price change from '1,490.00 kr' to '490,00 $ 1'. Is there any other way to change price format ? – Naved Ali Jul 01 '17 at 04:26

4 Answers4

1

After some research, I concluded that Format of currency displayed on the storefront is based on locale value for the CMSSite. It is out of the box feature of Localization and We can update it by following impex

UPDATE CMSSite;uid[unique=true];locale[lang=$lang]
 ;<site_uid>;<locale_value>

Also If we need to edit the format more, in that case we need to change to change the DataPriceFactory implementation.

Naved Ali
  • 616
  • 1
  • 14
  • 31
0

I believe you are trying to import using the HAC.

Please use the numberformat attribute modifier. Please note that you will have to specify the locale of the entries. To achieve a successful import, please follow the steps:

  1. Specify the locale: #% impex.setLocale( Locale.ENGLISH);
  2. Enable code execution in HAC

enter image description here

  1. Execute code using the numberformat modifier.

    INSERT_UPDATE Currency;isocode[unique=true];conversion;digits[numberformat==#.###,##];symbol ;ABC;1;24.953,87;kr

Please comment if you are still facing any issue.

Vikrant
  • 1,809
  • 1
  • 13
  • 18
  • Hey Vikarant, here am I not changing price format for particular product but all products for that region. I need to know how can I change number format of digits to #.###,##. What should I place at ? here. ;ABC;1;?;kr – Naved Ali Jul 05 '17 at 11:51
  • But this is automatically supported by the cmssite implementation. You need to provide the locale to the cmssite for your corresponding Swedish currency (I suppose, as you have mentioned symbol for Swedish krona). But as you specified region, I believe that region specific localization is not OOB. You have to either override the PriceFactory, or the CurrencyFormatter for that particular region. – Vikrant Jul 06 '17 at 04:33
  • check my comment on my question. I also tried setting locale but format got changed abruptly. I wrote output in that comment. – Naved Ali Jul 06 '17 at 04:36
  • Well my friend, in that case, you need to override the PriceFactory implementation for your region, as I said Region specific localization is not OOB in hybris. – Vikrant Jul 06 '17 at 04:38
  • Thanks for suggestion. Can you tell me in which file PriceFactory implementation code is written so that I can override it after reading. – Naved Ali Jul 06 '17 at 05:15
0

add the following line above the impex:

#% impex.setLocale( Locale.GERMAN );
INSERT_UPDATE Currency;isocode[unique=true];conversion;digits;symbol
;ABC;1;2;kr

set the corresponding localedo reach your expected format

Olivier Royo
  • 810
  • 10
  • 13
-1

I try you given locale with below code. It is look like sv_SE locale is not in standard jvm. May be you are using special configuration. Can you check it?

import java.text.*;
import java.util.*;

public class HelloWorld{

     public static void main(String []args){
        Locale locale = new Locale("sv","SE");
        DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(locale);
        DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
        System.out.println(symbols.getGroupingSeparator());
     }
}
mkysoft
  • 5,392
  • 1
  • 21
  • 30