OFBiz
  1. OFBiz
  2. OFBIZ-4412

Set initial ecommerce Locale/Currency based on mount point specified in specialpurpose/ecommerce/ofbiz-component.xm

    Details

    • Type: Improvement Improvement
    • Status: Patch Available
    • Priority: Trivial Trivial
    • Resolution: Unresolved
    • Affects Version/s: SVN trunk
    • Fix Version/s: None
    • Labels:
    • Environment:

      Not specific

      Description

      Using the specified patch, it is now possible to set a users initial Locale (and even currency) based on the webapp mount point. This works with a single store, and does not require the use virtual hosts. This is especially useful when setting up sitemap.xml, which allows crawlers (like google) to correctly locate and traverse products and services in multiple languages.

      Here is an example where "ecomclone" has been modified to Locale=fr with a mount point of "/fr".

      specialpurpose/ecommerce/ofbiz-component.xml:

      <!-- <init-param name="Currency" value="EUR"/> -->
      <webapp name="ecommerce"
      title="eCommerce"
      server="default-server"
      location="webapp/ecommerce"
      mount-point="/ecommerce"
      app-bar-display="false">
      </webapp>

      <webapp name="ecomclone"
      title="eCommerce Clone"
      server="default-server"
      location="webapp/ecomclone"
      mount-point="/fr" <------- SPECIFY MOUNT
      app-bar-display="false">
      <init-param name="Locale" value="fr"/> <------- SPECIFY LOCALE
      </webapp>

      The below sitemap.xml would allow products with the "/fr" path to be indexed in french.

      <?xml version="1.0" encoding="UTF-8"?>
      <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
      <url><loc>http://ofbizsite.com/ecommerce/products/10002/p_1001TANGRAMPUZ</loc></url>
      <url><loc>http://ofbizsite.com/fr/products/10002/p_1001TANGRAMPUZ</loc></url>
      </urlset>

      The patch:
      The attached patch modifies setDefaultStoreSettings in ProductEvents.java, which is called once during the initial session creation.

      After a user enters the URL, they are still free to modify the language, as long as the page supports it (like the default demo store). The patch also allows the Currency to be forced as well, and it does appear to work, but should be more throughly tested.

      Although this patch bypasses the requirement for multiple stores, there may be issues with other aspects of the store, like emails. However, it is no different than a user who enters your English-based ecommerce store, selects "french", and attempts a checkout.

        Activity

        Hide
        Jacques Le Roux added a comment -

        A look in archives might help, here are some related interesting threads

        4 feb 2007 http://markmail.org/message/ltxwhafxbgsnv4at
        The main event for this in the ecommerce controller.xml file is "setSessionCurrencyUom".
        -David

        15 dec 2007 http://markmail.org/message/z65kcj6xsgoztcwz
        It seems from a quick investigation that setSessionCurrencyUom is available in
        code but not (yet?) used in UI. I guess the idea is to use it if there is a need to allow user to choose his/her
        currency else the currency is determined by the store currency. Hence in your case it seems that you needs 2 stores else price in GBP will never
        show. Except if using setSessionCurrencyUom you implement a mean in UI for the user to choose himself/herself his/her currency.
        Jacques

        11 setp 2008 http://markmail.org/message/uinr5kjwjoucycwb
        Yes, David is right. My anwser was for OFBiz OOTB. If you want to customise to
        allow user to choose his/her currency have a look at setSessionCurrencyUom
        Jacques

        12 oct 2008 http://markmail.org/message/s4fnwkdt3m2cetsn
        Suppose I changed currency from $ to £ now all products prices, whose currencies has been configured in £ will be displayed.
        Problem come when we are on checkout screen as for shipping method cost is configured with single currency.
        example: if shipping method cost is 20 $ then it will display 20 £ which is incorrect (its just change the sign not the value).
        Please let me know is there a fix to it.
        Regards, Abhishake

        10 dec 2009 http://markmail.org/message/v53itkv6nqa3e5tj
        You may have products with proces in any currency you want. But you need one
        store for each currency. The rest of the workflow will follow, not sure how the accouting deal with that though...
        Jacques () ascii ribbon campaign against HTML e-mail /\ www.asciiribbon.org

        If all problems are resolved at the UI level, you still have 2 choices:

        1. Set all prices by currencies by products (fixed prices)
        2. or use foreign exchange rate table (dynamic prices). Then the problem is how and at which rate the foreign exchange rate table is updated.

        For dynamic prices, consider this experience/advice:

        3 feb 2007 http://markmail.org/message/w22tm3ssdrnhl3nj
        I've seen applications that use just 1 base/core currency for the entire store,
        and just do a real-time calculation (say with oanda exchange rate server) when a
        non-base/non-core currency is used.
        Personally, I don't see many stores handling > 1 currency. Taking in "fixed
        prices in foreign currencies" is actually quite bad for business, because that subjects the
        business to forex fluctuations.
        Imagine having a store with fixed price tags in EUR and in a currency
        (fictitious for illustration) WildMoney that fluctuates like mad. Now imagine shoppers coming in
        with WildMoney only on days when WildMoney is wildly weak against the EUR. This store will be
        losing a lot of money!
        Jonathon

        My personnal thought was (in the following message in thread)

        Yes I agree, and moreover sometimes prices are different according to countries
        (typical for luxury goods). But in some case it may be usefull to use an exchange rate server.
        Jacques

        In other words the choice between 1 & 2 depends on the domain (like a lot of choices). This does not mean that OFBiz OOTB should not provice those 2 choices... Interesting subject...

        HTH

        Show
        Jacques Le Roux added a comment - A look in archives might help, here are some related interesting threads 4 feb 2007 http://markmail.org/message/ltxwhafxbgsnv4at The main event for this in the ecommerce controller.xml file is "setSessionCurrencyUom". -David 15 dec 2007 http://markmail.org/message/z65kcj6xsgoztcwz It seems from a quick investigation that setSessionCurrencyUom is available in code but not (yet?) used in UI. I guess the idea is to use it if there is a need to allow user to choose his/her currency else the currency is determined by the store currency. Hence in your case it seems that you needs 2 stores else price in GBP will never show. Except if using setSessionCurrencyUom you implement a mean in UI for the user to choose himself/herself his/her currency. Jacques 11 setp 2008 http://markmail.org/message/uinr5kjwjoucycwb Yes, David is right. My anwser was for OFBiz OOTB. If you want to customise to allow user to choose his/her currency have a look at setSessionCurrencyUom Jacques 12 oct 2008 http://markmail.org/message/s4fnwkdt3m2cetsn Suppose I changed currency from $ to £ now all products prices, whose currencies has been configured in £ will be displayed. Problem come when we are on checkout screen as for shipping method cost is configured with single currency. example: if shipping method cost is 20 $ then it will display 20 £ which is incorrect (its just change the sign not the value). Please let me know is there a fix to it. Regards, Abhishake 10 dec 2009 http://markmail.org/message/v53itkv6nqa3e5tj You may have products with proces in any currency you want. But you need one store for each currency. The rest of the workflow will follow, not sure how the accouting deal with that though... Jacques () ascii ribbon campaign against HTML e-mail /\ www.asciiribbon.org If all problems are resolved at the UI level, you still have 2 choices: Set all prices by currencies by products (fixed prices) or use foreign exchange rate table (dynamic prices). Then the problem is how and at which rate the foreign exchange rate table is updated. For dynamic prices, consider this experience/advice: 3 feb 2007 http://markmail.org/message/w22tm3ssdrnhl3nj I've seen applications that use just 1 base/core currency for the entire store, and just do a real-time calculation (say with oanda exchange rate server ) when a non-base/non-core currency is used. Personally, I don't see many stores handling > 1 currency. Taking in "fixed prices in foreign currencies" is actually quite bad for business, because that subjects the business to forex fluctuations. Imagine having a store with fixed price tags in EUR and in a currency (fictitious for illustration) WildMoney that fluctuates like mad. Now imagine shoppers coming in with WildMoney only on days when WildMoney is wildly weak against the EUR. This store will be losing a lot of money! Jonathon My personnal thought was (in the following message in thread) Yes I agree, and moreover sometimes prices are different according to countries (typical for luxury goods). But in some case it may be usefull to use an exchange rate server. Jacques In other words the choice between 1 & 2 depends on the domain (like a lot of choices). This does not mean that OFBiz OOTB should not provice those 2 choices... Interesting subject... HTH
        Hide
        mz4wheeler added a comment -

        Thanks Dimitri. I also believe that the single store solution is the best way to go.

        I've been trying to get the Currency to display properly, but is doesn't seem to work unless individual prices in the currency are entered for each product. I really believe that only the default/list prices should be entered for the product (in default currency) and the displayed priced should be automatically calculated from the foreign exchange rate table.

        In productdetail.ftl, price is set via:

        <#assign price = priceMap?if_exists />

        However, if the session currency is EUR, and the actual product store is USD, it doesn't correctly render (or calculate) the price, as I would like to expect. However, add an item to the shopping cart, then view cart, and there it is, in EUR (odd).

        It would be great is someone with more OFBiz experience could figure this out. It is probably a simple fix.

        Show
        mz4wheeler added a comment - Thanks Dimitri. I also believe that the single store solution is the best way to go. I've been trying to get the Currency to display properly, but is doesn't seem to work unless individual prices in the currency are entered for each product. I really believe that only the default/list prices should be entered for the product (in default currency) and the displayed priced should be automatically calculated from the foreign exchange rate table. In productdetail.ftl, price is set via: <#assign price = priceMap?if_exists /> However, if the session currency is EUR, and the actual product store is USD, it doesn't correctly render (or calculate) the price, as I would like to expect. However, add an item to the shopping cart, then view cart, and there it is, in EUR (odd). It would be great is someone with more OFBiz experience could figure this out. It is probably a simple fix.
        Hide
        Dimitri Unruh added a comment -

        Just some notes:

        • I really don't want create for every language/currency an independent store with a independent webapp and so on...
          Just think abaout the whole maintenance
        • Google doesn't set any locale information, but google can explore the language the current page is using

        So, mz4wheeler, you are right. We have really a problem here. How can we tell google, that this is a multi-language website?

        In my opinion the URLs must look like:

        http://ofbizsite.com/ecommerce/fr/products/10002/p_1001TANGRAMPUZ
        http://ofbizsite.com/ecommerce/de/products/10002/p_1001TANGRAMPUZ
        http://ofbizsite.com/ecommerce/en/products/10002/p_1001TANGRAMPUZ
        

        And also there are many other things you have resolve:

        • canonical tag
        • duplicate content
        • site relation tag
        • cloaking
        • ....

        So, it could be a really nice task

        Show
        Dimitri Unruh added a comment - Just some notes: I really don't want create for every language/currency an independent store with a independent webapp and so on... Just think abaout the whole maintenance Google doesn't set any locale information, but google can explore the language the current page is using So, mz4wheeler, you are right. We have really a problem here. How can we tell google, that this is a multi-language website? In my opinion the URLs must look like: http: //ofbizsite.com/ecommerce/fr/products/10002/p_1001TANGRAMPUZ http: //ofbizsite.com/ecommerce/de/products/10002/p_1001TANGRAMPUZ http: //ofbizsite.com/ecommerce/en/products/10002/p_1001TANGRAMPUZ And also there are many other things you have resolve: canonical tag duplicate content site relation tag cloaking .... So, it could be a really nice task
        Hide
        BJ Freeman added a comment -

        Goggle search is pretty intelligent
        from my logs it looks like it changes the locale before reading the page.

        Show
        BJ Freeman added a comment - Goggle search is pretty intelligent from my logs it looks like it changes the locale before reading the page.
        Hide
        mz4wheeler added a comment -

        Yes, it should work (try it). You would have to make sure that you have all of the current exchange rates entered in the accounting module for all the various currencies.

        mount-point="/au"
        <init-param name="Locale" value="en_AU"/>
        <init-param name="Currency" value="AUD"/>

        I noticed that when I briefly tested the currency, the shopping cart seems to correctly exchange currencies (from the foreign exchange rate table) but the products only display the price correctly if the product has a price entered in the currency.

        Show
        mz4wheeler added a comment - Yes, it should work (try it). You would have to make sure that you have all of the current exchange rates entered in the accounting module for all the various currencies. mount-point="/au" <init-param name="Locale" value="en_AU"/> <init-param name="Currency" value="AUD"/> I noticed that when I briefly tested the currency, the shopping cart seems to correctly exchange currencies (from the foreign exchange rate table) but the products only display the price correctly if the product has a price entered in the currency.
        Hide
        Anne Jessel added a comment -

        I presume this would also work with mount-point /au having locale en-AU, mount-point /us having locale en-US, and mount-point /gb having locale en-GB (and corresponding currencies)?

        Show
        Anne Jessel added a comment - I presume this would also work with mount-point /au having locale en-AU, mount-point /us having locale en-US, and mount-point /gb having locale en-GB (and corresponding currencies)?
        Hide
        mz4wheeler added a comment -

        It is fairly easy to create a multi-language site in OFBiz using a SINGLE store. The user can easily change the language by either clicking a flag icon or selecting a drop-down. I also discovered that if you set the defaultLocale in the store to blank, then the users default locale can actually auto-select the correct locale if the language is supported by the OFBiz installation.

        So far so good. Now try to get Google to index the products in anything other than the store's default locale. You can't.

        So if you want to support 5 languages, you MUST set up 5 completely independent stores. Using the above method, you can setup multiple webapp clones (easy), and google and/or other crawler can correctly index your SINGLE store in as many languages as you want. Also, once it is indexed, and a user clicks the URL, the users locale will automatically be set to the locale of the page.

        Show
        mz4wheeler added a comment - It is fairly easy to create a multi-language site in OFBiz using a SINGLE store. The user can easily change the language by either clicking a flag icon or selecting a drop-down. I also discovered that if you set the defaultLocale in the store to blank, then the users default locale can actually auto-select the correct locale if the language is supported by the OFBiz installation. So far so good. Now try to get Google to index the products in anything other than the store's default locale. You can't. So if you want to support 5 languages, you MUST set up 5 completely independent stores. Using the above method, you can setup multiple webapp clones (easy), and google and/or other crawler can correctly index your SINGLE store in as many languages as you want. Also, once it is indexed, and a user clicks the URL, the users locale will automatically be set to the locale of the page.
        Hide
        Dimitri Unruh added a comment -

        In the productStore entity we already have defaultCurrencyUomId and defaultLocaleString.
        Why do we need one more setting?

        Show
        Dimitri Unruh added a comment - In the productStore entity we already have defaultCurrencyUomId and defaultLocaleString. Why do we need one more setting?

          People

          • Assignee:
            Unassigned
            Reporter:
            mz4wheeler
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 2h
              2h
              Remaining:
              Remaining Estimate - 2h
              2h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development