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: Closed
    • Priority: Trivial Trivial
    • Resolution: Incomplete
    • Affects Version/s: 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.

        Issue Links

          Activity

          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?
          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
          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 -

          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
          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
          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
          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
          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
          Jacques Le Roux added a comment -

          Since this issue is questioning about SEO and urls, I want to mention it's related with OFBIZ-5312

          Show
          Jacques Le Roux added a comment - Since this issue is questioning about SEO and urls, I want to mention it's related with OFBIZ-5312
          Hide
          Josip Almasi added a comment - - edited

          I can confirm this works - after fixing shopping cart currency: OFBIZ-5767

          Show
          Josip Almasi added a comment - - edited I can confirm this works - after fixing shopping cart currency: OFBIZ-5767
          Hide
          mz4wheeler added a comment -

          Great news Josip. The patch was primarily meant to associate a particular locale to a mount point, so Google could pick up (and index) all language versions of the same page. The patch also allows the currency to be set via a mount point via:

          <init-param name="Currency" value="EUR"/>

          And although the page properly rendered the new currency, the checkout process was still broken. Your other patch addressed this currency bug, Thanks!

          You mentioned in another email that the patch posted (here) is out of date, and that you had to manually apply it. Would you have a new patch that can be posted? Thanks.

          Show
          mz4wheeler added a comment - Great news Josip. The patch was primarily meant to associate a particular locale to a mount point, so Google could pick up (and index) all language versions of the same page. The patch also allows the currency to be set via a mount point via: <init-param name="Currency" value="EUR"/> And although the page properly rendered the new currency, the checkout process was still broken. Your other patch addressed this currency bug, Thanks! You mentioned in another email that the patch posted (here) is out of date, and that you had to manually apply it. Would you have a new patch that can be posted? Thanks.
          Hide
          Josip Almasi added a comment -

          Sorry Mike, your patch is fine, my bad.

          Show
          Josip Almasi added a comment - Sorry Mike, your patch is fine, my bad.
          Hide
          mz4wheeler added a comment -

          Jacques, here is an example of this patch.

          Josip has created two mount points, setting the currency and language:

          "/shophr" = Croatian kuna
          "/shopde" = German EUR

          Also, assuming there is a sitemap.xml that lists all URLs with the various mount points.

          wget -S -O - http://www.mikrotron.hr/shophr/products/ArduinoBoards/p_10000 2>&1 | grep -i lang=
          <html xmlns="http://www.w3.org/1999/xhtml" lang="hr" xml:lang="hr">

          wget -S -O - http://www.mikrotron.hr/shopde/products/ArduinoBoards/p_10000 2>&1 | grep -i lang=
          <html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">

          Google would see the LANG variable and index the page in each language.

          I also did this (this is what google would do):

          wget -S -O - http://www.mikrotron.hr/shophr/products/ArduinoBoards/p_10000 2>&1 | grep regularPrice
          Your Price: <span class="regularPrice">113,00 kn</span>

          wget -S -O - http://www.mikrotron.hr/shopde/products/ArduinoBoards/p_10000 2>&1 | grep regularPrice
          Ihr Preis: <span class="regularPrice">14,79 €</span>

          This is all with a single store. He married OFBIZ-4412 and OFBIZ-5767.

          Show
          mz4wheeler added a comment - Jacques, here is an example of this patch. Josip has created two mount points, setting the currency and language: "/shophr" = Croatian kuna "/shopde" = German EUR Also, assuming there is a sitemap.xml that lists all URLs with the various mount points. wget -S -O - http://www.mikrotron.hr/shophr/products/ArduinoBoards/p_10000 2>&1 | grep -i lang= <html xmlns="http://www.w3.org/1999/xhtml" lang="hr" xml:lang="hr"> wget -S -O - http://www.mikrotron.hr/shopde/products/ArduinoBoards/p_10000 2>&1 | grep -i lang= <html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de"> Google would see the LANG variable and index the page in each language. I also did this (this is what google would do): wget -S -O - http://www.mikrotron.hr/shophr/products/ArduinoBoards/p_10000 2>&1 | grep regularPrice Your Price: <span class="regularPrice">113,00 kn</span> wget -S -O - http://www.mikrotron.hr/shopde/products/ArduinoBoards/p_10000 2>&1 | grep regularPrice Ihr Preis: <span class="regularPrice">14,79 €</span> This is all with a single store. He married OFBIZ-4412 and OFBIZ-5767 .
          Hide
          Josip Almasi added a comment - - edited

          ... and I also had to modify
          specialpurpose/ecommerce/webapp/ecommerce/includes/headerHead.ftl
          in order to add html/xhtml lang:
          OFBIZ-5772
          Now I'm not sure about dependencies here.
          I had to apply all three to get what I needed - single store with multiple languages and currencies.

          Show
          Josip Almasi added a comment - - edited ... and I also had to modify specialpurpose/ecommerce/webapp/ecommerce/includes/headerHead.ftl in order to add html/xhtml lang: OFBIZ-5772 Now I'm not sure about dependencies here. I had to apply all three to get what I needed - single store with multiple languages and currencies.
          Hide
          Jacques Le Roux added a comment -

          As a note here OFBIZ-5772 was a duplicate of OFBIZ-4899 but the fix in OFBIZ-4899 had not been backported in R12 ands R11, done now.

          Show
          Jacques Le Roux added a comment - As a note here OFBIZ-5772 was a duplicate of OFBIZ-4899 but the fix in OFBIZ-4899 had not been backported in R12 ands R11, done now.
          Hide
          Jacques Le Roux added a comment - - edited

          OFBIZ-5767 has been reverted has explained there, so this issue no longer makes sense to me. We should rather put our effort in OFBIZ-5312. I close here as incomplete.

          I don't think the "one store for all currencies" is currently viable. This could be revisited though, note that it can be more complicated if you take the multi-tenant feature into account...

          Show
          Jacques Le Roux added a comment - - edited OFBIZ-5767 has been reverted has explained there, so this issue no longer makes sense to me. We should rather put our effort in OFBIZ-5312 . I close here as incomplete. I don't think the "one store for all currencies" is currently viable. This could be revisited though, note that it can be more complicated if you take the multi-tenant feature into account...

            People

            • Assignee:
              Jacques Le Roux
              Reporter:
              mz4wheeler
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

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

                  Development