Sample: Loading Commerce Composer widget descriptive information in multiple languages
This sample demonstrates how to load descriptive information for Commerce Composer in multiple languages for use in Management Center and on the storefront.
Before beginning
This sample requires a published store that is based on the Aurora starter store and the Commerce Composer tool. Ensure that the following tasks are complete:
- Review the Commerce Composer data load best practices. Follow these best practices when loading Commerce Composer assets with the Data Load utility.
About this sample
If you have Commerce Composer widgets for the store, we can use the Data Load utility to load descriptive information for the widgets in more languages. This sample loads the descriptive information for a widget in two languages, English (en_US), and French (fr_FR). For more information about the languages that are supported by default, see Supporting globalization.
Before we can load the descriptive information for a widget, the widget must be created, registered, and subscribed to a store. For more information about creating widgets, see Creating Commerce Composer widgets. For more information about loading information to register and subscribe widgets to a store, see Sample: Loading Commerce Composer widgets. We can load this sample information in both CSV or XML formatted input files. The following procedure, however, loads only the CSV input files. If you prefer to work with the data within the XML formatted files, we can edit the sample configuration files to use the XML files. The sample input files are located within the following directory:
- (Linux) utilities_root/samples/DataLoad/CommerceComposer/widget/MultiLanguages
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\widget\MultiLanguages
To load this sample, we can load the multiple language information is separate files or within a single file.
- To load the information in a single file, load the wc-dataload-widgetdefdesc-one-step-lang.xml data load order configuration file. When you run this load order file, the Data Load utility loads the information within the registerWidgetdefdescWithTwoLanguages.csv sample input file. The registerWidgetdefdescWithTwoLanguages.csv contains multiple description and display name columns. Both description columns are mapped to the same database column. Both display name columns are also mapped to the same column. The business object configuration file however configures the Data Load utility to create separate entries for the widget within the database, one for each language.
Note: The configuration that handles the loading of information in multiple languages for this option is defined within the business object configuration file.
- To load the multiple language information in separate files, load the wc-dataload-widgetdefdesc-two-step-lang.xml. When you load this file, the Data Load utility loads the information within the registerWidgetdefLanguageOne.csv and registerWidgetdefdescLanguageTwo.csv sample input files. The registerWidgetdefLanguageOne.csv file includes the information to register the widget and default language (English) information. The registerWidgetdefdescLanguageTwo.csv includes the information to load the French language information for the widget.
Note: When we use the separate file approach, the configuration that identifies the language that data is being loaded within is defined within the data load order configuration file.
If we are using this sample to help you load Commerce Composer widget information that exists in another instance, we can use the Data Extract utility to generate the input files for loading your widget data. We can use the Data Extract utility to extract the existing widget registration data. Then, we can edit configuration files for this sample to load the files that are generated by the Data Extract utility. For a sample that demonstrates how to use the Data Extract utility to extract widget data, see Sample: Extracting Commerce Composer widgets. Since the Data Extract utility sample files extract the widget descriptive information for all languages in a single file, use the single file approach to load the extracted data.
The following table lists the sample input files that are use to load the data in this sample. The table also identifies the business object mediators and business object configuration files that the Data Load utility uses to load the sample data.
Sample input file Description CSV
- registerWidgetdefLanguageOne.csv
XML
- registerWidgetdefLanguageOne.xml
For more information about the type of data within the input file, see registerWidgetdef input file
The Data Load utility loads the information to register a widget for use in the Commerce Composer tool.
The Data Load utility loads the descriptive information within the input files into the PLWIDGETDEF, and PLWIDGETDEFDESC database tables. The Data Load utility uses the following business object mediator and business object configuration file to load the data within this input file:
Business object mediator
com.ibm.commerce.pagelayout.dataload.mediator.RegisterWidgetDefMediator Business object configuration file
- (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-registerWidgetdef.xml
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-registerWidgetdef.xml
CSV
- registerWidgetdefdescLanguageTwo.csv
XML
- registerWidgetdefdescLanguageTwo.xml
For more information about the type of data within the input file, see registerWidgetdefdesc input file
The Data Load utility loads the descriptive information of a widget in multiple languages.
The Data Load utility loads the descriptive information within the input files into the PLWIDGETDEF, and PLWIDGETDEFDESC database tables. The Data Load utility uses the following business object mediator and business object configuration file to load the data within this input file:
Business object mediator
com.ibm.commerce.pagelayout.dataload.mediator.RegisterWidgetDefMediator Business object configuration file
- (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-registerWidgetdefdesc.xml
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-registerWidgetdefdesc.xml
CSV
- registerWidgetdefdescWithTwoLanguages.csv
XML
- registerWidgetdefdescWithTwoLanguages.csv
This sample input file contains the information to register the widget and the widget descriptive information within a single file. This sample file includes the contents of both the registerWidgetdefLanguageOne.csv and registerWidgetdefdescLanguageTwo.csv sample input files. Business object mediator
com.ibm.commerce.pagelayout.dataload.mediator.RegisterWidgetDefMediator Business object configuration file
- (Linux) utilities_root/samples/DataLoad/CommerceComposer/widget/MultiLanguages/wc-loader-registerWidgetdefdesc-two-langs.xml
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\widget\MultiLanguages\wc-loader-registerWidgetdefdesc-two-langs.xml
Procedure
(Developer) On a command line, go to the WCDE_installdir\bin directory.
- (Linux) Open a command line in the Utility server Docker container. Change the directory to utilities_root/bin directory.
For information about entering and leaving containers, see Running utilities from the Utility server Docker container.- Enter the following command to run the sample data load order file to load the widget descriptive information in multiple languages:
- To load the descriptive information within a single sample input file:
- (Linux) ./dataload.sh ../samples/DataLoad/CommerceComposer/widget/MultiLanguages/wc-dataload-widgetdefdesc-one-step-lang.xml
(Developer) dataload ..\samples\DataLoad\CommerceComposer\widget\MultiLanguages\wc-dataload-widgetdefdesc-one-step-lang.xml
- To load the descriptive information within separate sample input files:
- (Linux) ./dataload.sh ../samples/DataLoad/CommerceComposer/widget/MultiLanguages/wc-dataload-widgetdefdesc-two-step-lang.xml
The load order configuration file identifies the order that the Data Load utility loads the sample CSV files. The load order file also identifies the appropriate business object configuration file to use to load each input file. For more information about load order configuration files,
Configure the data load order.For more information about configuring and running the Data Load utility, see Configure and running the Data Load utility.
Verifying results
Verify that the Commerce Composer tool widget information is loaded by reviewing the data load summary report. For more information about the location and contents of this summary report, see Verifying the results of the data load. We can also verify that the sample data is loaded by running the following SQL statements against the WebSphere Commerce database:
select * from PLWIDGETDEF where IDENTIFIER like 'Sample%'; select * from PLWIDGETDEFDESC where PLWIDGETDEF_ID in (select PLWIDGETDEF_ID from PLWIDGETDEF where IDENTIFIER like 'Sample%'); select * from PLSTOREWIDGET where PLWIDGETDEF_ID in (select PLWIDGETDEF_ID from PLWIDGETDEF where IDENTIFIER like 'Sample%');Ensure that the data within the sample input files exists within the appropriate database tables.
In Management Center, verify that users can view the French language description for the widget in the Commerce Composer tool. Log on to Management Center in the French language and create a layout for a page. When we are creating the layout, select a template slot to add a widget to the slot. Ensure that the appropriate language description for the widget shows in the Add Widgets to Slots window.
Removing the sample data from the WebSphere Commerce database
To remove the sample data from the database, run the sample again but with the value for the delete column for all entries within the files set to 1. By setting the value for this column to 1, the Data Load utility deletes the data that is identified in the CSV file from the database.