Adding extension logic to all store pages

You can configure the Aurora starter store to include custom extension logic, such as self contained JSP on all store pages. By using this configuration, you can easily embed common code on all store pages, or embed code for tracking the browsing history of shoppers.

About this task

By default, all store pages for the Aurora starter store include the JSPFExtToInclude.jspf file, which dynamically retrieves custom extension JSP files for the store pages. The JSPFExtToInclude.jspf file is used to retrieve a list of configuration entries in the STORECONF database table that belong to the store ID for the store pages. The store page JSP files then include the file that is specified in the value column for each entry.

WebSphere Commerce EnterpriseIf your site uses an extended sites store model, you can add extension logic to all store pages for any or all stores. You can add entries into the STORECONF table using the ID for either the storefront asset store or a specific store. The list of files that are added to the pages for a store, include the value for all entries for that specific store and for the storefront asset store.

When you are loading a custom JSP file as an entry in the STORECONF table, your file might need to include any environment setup files that your JSP file might need. You can include an environment setup file within your custom JSP file with an include statement, for example:
<%@ include file="/Widgets/Common/EnvironmentSetup.jspf"%> 
You can add entries into the STORECONF table with the Data Load utility or manually with an SQL file or insert statements. The following steps demonstrate how to use the Data Load utility to load information into this table. If you want to manually update the table with SQL, use the following insert statement format:
insert into storeconf (storeent_id, name, value, optcounter)values (storeent_id, 'name', 'value', 0); 
Where
STOREENT_ID
The store identifier, which identifies the store that is updated to include logic on all pages. For example, 10001
NAME
The name of the configuration entry. The prefix 'wc.pgl.jspInclude_' must be declared in the name for a store to include logic within the body of store pages. To include logic within the header section of store pages, use the prefix 'wc.pgl.jspIncludeHead_' in the name.

If your site uses logic from multiple vendors, include the vendor name in the name of the configuration entry. For example, 'wc.pgl.jspInclude_vendor_SiteMap' Where vendor is the name of your company or the company that provides the logic. The value of the name field must be unique for a store in the STORECONF table.

VALUE
The value of the relative path for the configuration entry. This relative path points to the extension JSP fragment file that you want to include in every store page. For example, '/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp'
If you are loading entries to configure store pages to include a site map for multiple stores, your SQL statements can resemble the following statements.
insert into storeconf (storeent_id, name, value, optcounter) values (10001, 'wc.pgl.jspInclude_myCompany_SiteMap', 
'/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp', 0);
insert into storeconf (storeent_id, name, value) values (10152, 'wc.pgl.jspInclude_myCompany_SiteMap', 
'/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp', 0);
insert into storeconf (storeent_id, name, value) values (10751, 'wc.pgl.jspInclude_myCompany_SiteMap', 
'/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp', 0);

Procedure

  1. Create the CSV file and Data Load utility configuration files for loading your store configuration information. To help you create these files, WebSphere Commerce provides sample CSV and configuration files. Use these sample files to model your CSV and configuration files.
    1. Create a directory to include the CSV files and Data Load utility configuration files for loading layout template information. You can create this directory anywhere within your file system, however for the following steps a StoreConfiguration-MyCompany directory is created within the WCDE_installdir\components\foundation\samples\DataLoad directory.
    2. Go to the WCDE_installdir\components\foundation\samples\DataLoad\StoreConfiguration directory. Copy the contents of the StoreConfiguration directory. This directory includes the sample CSV files and configuration files for loading store configuration information.
    3. Add the copied files into your StoreConfiguration-MyCompany directory.
    4. In your StoreConfiguration-MyCompany directory, open the StoreConfiguration.csv file for editing.
      By default, this file includes the required columns for loading store configuration information and sample data. Delete the sample data within this file. Do not remove any of the columns or the StoreConfiguration keyword within the file. Add the data for your custom layout template container into the file.
      Within your CSV file, set the following column values
      STOREENT_ID
      Optional. You do not need to include the STOREENT_ID column or value. By default the data load process loads information for the store that is configured within the wc-dataload-env.xml environment configuration file. Include this column if you want to load data for a different store than the store configured within the environment configuration file.
      NAME
      The name of the configuration entry. Include the prefix 'wc.pgl.jspInclude_' or 'wc.pgl.jspIncludeHead_' in the name. If your site uses logic from multiple vendors, include the vendor name in the name of the configuration entry.
      VALUE
      The value of the relative path for the configuration entry. This relative path points to the extension JSP fragment file that you want to include in every store page.
      Delete
      Optional. Indicates whether to delete a store configuration entry. Set the value for this column to 1 to delete the entry. If you do not set a value, the value defaults to 0 and the entry loads into the STORECONF table.
    5. Save and close your CSV input file.
      Your file can resemble the following file contents:
      StoreConfiguration
      STOREENT_ID,Name,Value,Delete
      10001,wc.pgl.jspInclude_myCompany_SiteMap,/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp,0
      10152,wc.pgl.jspInclude_myCompany_SiteMap,/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp,0
      10751,wc.pgl.jspInclude_myCompany_SiteMap,/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp,0
  2. Configure the Data Load utility
    You do not need to update the copied data load order configuration file, wc-dataload-store-configuration.xml, or the business object configuration file, wc-loader-store-configuration.xml. You must configure your data load environment configuration file.
    1. Open the wc-dataload-env.xml data load environment configuration file for editing.
      This file configures the Data Load utility environment variables, such as the database settings, ID resolver, and data writer.
    2. Update the file to match your database and environment settings.
      For more information, see Configuring the data load environment settings. You can enter a value for your store identifier in this file or enter the store identifier within your CSV file to load the CSV files. The store identifier is used to identify the store that subscribes to your layout template. The store identifier is case-sensitive. You can find the value for your store identifier within the IDENTIFIER column of the STOREENT database table.
    3. Save your file.
  3. Run the Data Load utility.
    1. In a command-line utility, go to the WCDE_installdir\bin directory.
    2. Run the following command to load the input files to register and define your layout template, and have your store subscribe to the template.

      dataload.bat ..\components\foundation\samples\DataLoad\StoreConfiguration-MyCompany\wc-dataload-store-configuration.xml

    3. Verify the results of the data load.
  4. Verify that extension logic configuration property is successfully loaded into the STORECONF table.
    Run the following SQL command:
    Select * from storeconf;
    Ensure that your extension logic configuration properties display in the returned database contents. For example, the STORECONF table results can resemble:
    STOREENT_ID NAME VALUE
    10001 'wc.pgl.jspInclude_myCompany_SiteMap' '/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp'
    10152 'wc.pgl.jspInclude_myCompany_SiteMap' '/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp'
    10751 'wc.pgl.jspInclude_myCompany_SiteMap' '/Widgets/com.myCompany.commerce.store.widgets.SiteMap/SiteMap.jsp'