Group locales by country and store

In this optional lesson, you will group your new locales by country and separate them by store. Grouping locales by country and store ensure that a store in a particular country only has the languages it requires.

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 you will publish two stores. Using WebSphere Commerce Accelerator you will change the profile of each store assigning 'storeA' only United States English in the Selected Languages list, and store 'storeB' only Canadian English and Canadian French in the Selected Languages list.

Creating stores for each country

About this task

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

Procedure

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

Results

Mapping locales to your store

About this task

Follow these steps to map your locale to your stores.

Procedure

  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:
      • Windows <wc>\instances\<instance>\httpconf
      • AIX <wc>\instances\<instance>\httpconf
      • Linux <wc>\instances\<instance>\httpconf
    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:
    • Windows drive:\WebSphere\HTTPServer
    • AIX /usr/HTTPServer
    • Linux /opt/HTTPServer
  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 -24 for Canadian English, then use the following URL: http://localhost/webapp/wcs/stores/servlet/StoreView?storeId=10001&langId=-24
    • If the Store reference number is 10001 and the language number is -25 for Canadian French, then use the following URL: http://localhost/webapp/wcs/stores/servlet/StoreView?storeId=10001&langId=-25
  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 Environment section and click on Virtual Hosts.
    3. Select the virtual hosts for your WebSphere Commerce instance. For example, VH_demo and VH_demo_tools.
    4. Under the Additional Properties tab, click on Hosts Aliases. Add the hostname to the list of aliases. For example:
      www.storeA.com
      www.storeA.com:443
      <--- newly added www.storeB.ca <--- newly added
      <--- 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, you will need to 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).

Results

You have now grouped the locales by country, and separated them by store. In turn, you now have added two fully functional locales to your WebSphere Commerce instance.