Step 4: Group locales by country and store

In this step of the tutorial, you will learn how to group your new locales by country and separate then by store.

There may be times when a locale ending in _US or a locale ending in _CA may be the deciding factor in how a store is created. All locales ending in _US we can assume are United States stores. All locales ending in _CA we can assume are Canadian stores. For our example, en_CA and fr_CA both apply to the same store. To do this it is necessary to publish two stores. Then use Commerce Accelerator to change the profile of each store. Store 'storeA' holds only United States English in the Selected languages box. Store 'storeB' holds only Canadian English and Canadian French in the selected languages box. When this is finished, it would be an advantage to configure your WebSphere Commerce instance to respond to different site names according to your locales. The following link is a good example: http://www-1.ibm.com/support/docview.wss?rs=497&context=SSPK6A&context=SSZLC2&q1=8000&uid=swg21165705&loc=en_US&cs=utf-8&lang=en+en. The following instructions use IBM HTTP Server as an example of using name-based virtual hosts to achieve this task for two stores running in the same WebSphere Commerce instance.

Follow these steps to create two stores for your two locales:

  1. Publish your store through the Administration Console
    1. Logon using your user id and password
    2. On the Site / Store Selection page make sure the Site radio box is selected
    3. Click OK
    4. Click Store Archives and select Publish
    5. Follow the publish wizard to publish your store
    6. Click Store Archives > Publish Status and Refresh until your store has successfully published
    7. logoff of the Administration Console
  2. Publish a second store through the Administration Console following the directions of step 1 above.
  3. Change your stores profiles
    1. Logon to the Commerce Accelerator
    2. Select your store from the Select Store and Language page
    3. Click OK
    4. Click Store > Change Profile
    5. Set your languages
      • For the first store make sure United States English is in the Selected Languages list and is set as the default languages.
      • For the second store move Canadian English and Canadian French from the Available Languages to the Selected Languages and click Set as Default Language
    6. Click OK

Follow these steps to map your locale to your stores:

  1. Ensure that your host names can be resolved to the same IP address, which will depend on your domain registry. However, for local testing, you can add entries in your host files as follows:

    192.168.0.1
    www.storeA.com
    192.168.0.2
    www.storeB.ca

  2. Update the HTTP Server configuration:
    1. Open the httpd.conf file in a text editor, located in the following directories for the indicated operating systems:
    2. Add the following line to the virtual host portion of the configuration:
      NameVirtualHost *
    3. Update the existing virtual host settings. By default, the virtual host for your WebSphere Commerce instance should look like this:
      <VirtualHost  www.storeA.com>
           <ServerName  www.storeA.com>
           DocumentRoot  "C:/WebSphere/HTTPServer/htdocs" 
      
                              <!-- ...... -->
                     <VirtualHost  www.storeA.com:443>
                     <ServerName  www.storeA.com>
                     DocumentRoot  "C:/WebSphere/HTTPServer/htdocs"
                              <!-- ...... -->
                     <VirtualHost  www.storeA.com:8000>
                     <ServerName  www.storeA.com>
                     DocumentRoot  "C:/WebSphere/HTTPServer/htdocs"
      

      Update the virtual host settings to look like the following extract:

      <VirtualHost  *>
                     <ServerName  www.storeA.com>
                     DocumentRoot  "C:/WebSphere/HTTPServer/htdocs" 
      
                               <!--......-->
                     <VirtualHost  *:443>
                     <ServerName  www.storeA.com>
                     DocumentRoot  "C:/WebSphere/HTTPServer/htdocs"
                               <!--......-->
                     <VirtualHost  *:8000>
                     <ServerName  www.storeA.com>
                     DocumentRoot  "C:/WebSphere/HTTPServer/htdocs"
      
    4. Create a new set of virtual hosts for the second store and update the ServerName and DocumentRoot. Your new set of virtual hosts should look like this extract:
      <VirtualHost  *>
                   <ServerName  www.storeB.ca>
                   DocumentRoot  "C:/WebSphere/HTTPServer/htdocs_storeB" 
      
                               <!--......-->
                   <VirtualHost  *:443>
                   <ServerName  www.storeB.ca>
                   DocumentRoot  "C:/WebSphere/HTTPServer/htdocs_storeB"
                               <!--......-->
                   <VirtualHost  *:8000>
                   <ServerName  www.storeB.ca>
                   DocumentRoot  "C:/WebSphere/HTTPServer/htdocs_storeB" 
      
    5. Save your changes and close the httpd.conf file.
  3. Create the document root for your second store. Create a new folder called htdocs_storeB under the following directories:
  4. Create a new index.html file under the new directory. This index.html file will be used to redirect to a second WebSphere Commerce store. For example:
    <HTML>
    <HEAD></HEAD>
    <TITLE>www.storeB.ca</TITLE>
    
    <SCRIPT LANGUAGE="JavaScript">
    function redirect() {
         window.location.href="/webapp/wcs/stores/servlet/StoreB/index.jsp";
    } 
    
    <BODY onLoad="redirect()"></BODY>
    </HTML>
    
    Note: The above URL could also be routed to a store that all locales share. To do this, instead of pointing to StoreB, point to the same store and specify the language identifier in order to open the store with a specified language.
    For example:
    • If the Store reference number is 10001 and the language number is 124 for Canadian English, then use the following URL: http://localhost/webapp/wcs/stores/servlet/StoreView?storeId=10001&langId=124
    • If the Store reference number is 10001 and the language number is 125 for Canadian French, then use the following URL: http://localhost/webapp/wcs/stores/servlet/StoreView?storeId=10001&langId=125
  5. (Optional) If you have not already done so, you might want to create an index.html file under the previous document root to redirect to the first store. For example, drive:\WebSphere\HTTPServer\htdocs for Windows.
  6. Update the virtual host configuration in WebSphere Application Server.
    1. Open the WebSphere Application Server Administrative Console.
    2. Expand the WebSphere Administrative Domain and select Virtual Host.
    3. Select the virtual hosts for your WebSphere Commerce instance. For example, VH_demo and VH_demo_tools.
    4. Under the General tab, add the host name to the list of aliases. For example: &br www.storeA.com &br www.storeA.com:443 &br <--- newly added www.storeB.ca <--- newly added &br <--- newly added www.storeB.ca:443 <--- newly added
    5. Click Apply to save the changes.
    6. Regenerate your WebServer Plug-in. If you are using a remote Web server, copy this file to the remote machine after regeneration).
  7. Restart the HTTP Server. The HTTP Server must be restarted to recognize the changes to httpd.conf and the WebSphere Plug-in file. Once the HTTP Server is restarted, the stores should be accessible using their separate names (for example, www.storeA.com and www.storeB.ca).