Sample: Extracting Commerce Composer layouts
This sample demonstrates how to extract Commerce Composer layouts for a store with the Data Extract utility. We can then use the Data Load utility to load the extracted data into another WebSphere Commerce instance or store to quickly copy layouts between instances or stores.A layout is an arrangement of layout widgets within a layout template used to render a store page. A layout contains one or more widgets that are placed in specific slots in the template. The properties (name-value pairs) of each widget within a layout are set to specific values. For more information about layouts, see Layouts, layout templates, and default layouts.
Before beginning
Ensure that you complete the following tasks:
- Verify that the store to extract data from includes Commerce Composer layout data to extract.
Note: If you plan to load the extracted data into another instance, the store to load data into must have the Commerce Composer tool enabled. The Aurora starter store is enabled to use the Commerce Composer tool.
About this sample
When you run this sample, the Data Extract utility is configured to extract the layouts for only the store that you specify. We can specify the store in the environment configuration file or directly in the command line when you run the utility.
When you run this sample, the utility also extracts the layout template data and the relationship data for any widgets assigned to the layouts for the specified store. Data for the layout widgets that are registered or subscribed to a store is not extracted. We must extract this widget data in a separate operation. For more information about extracting this widget data, see Sample: Extracting Commerce Composer widgets. The sample configuration files used to configure the Data Extract utility are in the following directory and subdirectories:
(Developer) WCDE_installdir\samples\DataExtract\CommerceComposer
Sample configuration files
The following configuration files are used to configure the Data Extract utility to extract data into CSV output files.
- wc-dataextract-env.xml
- The environment configuration file. This file includes the environment variables for the WebSphere Commerce instance. These variables include the following information:
- Business context variables, including the store identifier, catalog identifier, and the default language and currency for the store.
- Database environment settings, including the database type, name, and schema.
- wc-dataextract-layout.xml
- The data extract order configuration file. This file specifies the paths to the environment configuration file and to the business object configuration files for extracting the data for each type of object. The order configuration file also identifies the order that the Data Extract utility extracts data and identifies the output files that the utility generates to include the extracted data.
- wc-extract-business-object.xml
- The business object configuration file. This file defines how the utility identifies the data to extract and defines the business object mediator for the utility to use to transform the extracted data. In this sample, all of the business object configuration files configure the utility to use the following business object mediator:
com.ibm.commerce.foundation.dataload.businessobjectmediator.AssociationObjectMediator The following business object configuration files are used to configure the Data Extract utility for this sample:
- wc-extract-registerWidgetdef.xml
- This file is used to configure the utility to extract layout template container registration data. The utility extracts this data from the following database tables:
The utility generates the registerWidgetdef.csv file to include the extracted data. This file can then be used to load data for registering a new layout template container within the Commerce Composer tool. For more information about the data that can be included in this file, see registerWidgetdef input file
- wc-extract-subscribeWidgetdef.xml
- There are 2 wc-extract-registerWidgetdef.xml files used in this sample. These files are used to configure the utility to extract widget and layout template container subscription data. The utility extracts the data for both types of objects from the following database table:
The utility generates 2 subscribeWidgetdef.csv output files to include the extracted data. These files can then be used to load the data for subscribing widgets and layout template containers to a store.
- The subscribeWidgetdef.csv file in the layout directory includes widget subscription data.
- The subscribeWidgetdef.csv file in the template directory includes layout template container subscription data.
For more information about the data that can be included in these files, see subscribeWidgetdef input file.
- wc-extract-template.xml
- This file is used to configure the utility to extract basic layout template data. The utility extracts this data from the following database table:
The utility generates the template.csv output file to include this extracted data. This file can then be used to load the data to create layout templates in the Commerce Composer tool. For more information about the data that can be included in this file, see template input file.
- wc-extract-slotDefinition.xml
- This file is used to configure the utility to extract the wireframe slot definitions for layout templates. Each wireframe slot is defined with X and Y coordinates and is used to organize widgets within a layout. The utility extracts this data from the following database table:
The utility generates the slotdefinition.csv output file to include the extracted data. This file can then be used to load the data to assign the wireframe coordinates to a template. For more information about the data that can be in this file, see slotDefinition input file
- wc-extract-pagelayout.xml
- This file is used to configure the utility to extract basic layout data for the layouts that exist for a store. The utility extracts this data from the following database tables:
The utility generates the layout.csv output file to include the extracted data. This file can then be used to load the data to create layouts in a store. For more information about the data that can be in this file, see layout input file.
- wc-extract-widget.xml
- This file is used to configure the utility to extract relationship data for assigning widgets and layout template containers to layouts. The utility extracts this data from the following database tables:
The utility generates the layoutWidgetRelationship.csv file to include the extracted data. This file can then be used to assign widgets to layouts in another store or instance. For more information about the data that can be in this file, see layoutWidgetRelationship input file.
- wc-extract-widgetnvp.xml
- This file is used to configure the utility to extract data for the name-value pair properties of widgets assigned to layouts. The utility extracts this data from the following database table:
The utility generates the widgetnvp.csv file to include the extracted data. This file can then be used to configure the properties for widgets assigned to the layouts for a store. For more information about the data that can be in this file, see widgetnvp input file.
Procedure
- Copy the sample configuration files and directories to a local directory.
- Edit your copy of the sample environment configuration file to set the configuration variables for the environment. The sample configuration file used in this sample includes values for a default WebSphere Commerce Developer environment that uses an Apache Derby database. If the environment settings are different, change the configured values in the environment configuration file to match the environment. For more information about updating an environment configuration file, see Configure the data load environment settings.
(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 extract order configuration for extracting the layout data into CSV output files:
- (Linux) ./dataextract.sh ../samples/DataExtract/CommerceComposer/wc-dataextract-layout.xml
(Developer) dataextract ..\samples\DataExtract\CommerceComposer\wc-dataextract-layout.xml
When the utility completes the extraction process, the utility generates the CSV output files within the configured output directory and subdirectories. These files include data for all layouts that exist for the configured store ID. These files also include the data for the layout templates used by the layouts and the relationship data for any widgets assigned to the layouts. By default, the files are generated in the following output directory and subdirectories:
- (Linux) utilities_root/samples/DataExtract/CommerceComposer/output
(Developer) WCDE_installdir\samples\DataExtract\CommerceComposer\output
Verifying results
- Go to the directory that you configured as the output directory. If we did not configure an output directory, go to the following directory:
- (Linux) utilities_root/samples/DataExtract/CommerceComposer/output
(Developer) WCDE_installdir\samples\DataExtract\CommerceComposer\output
- Verify that the following CSV output files are generated:
- template/registerWidgetdef.csv
- template/subscribeWidgetdef.csv
- template/template.csv
- template/slotDefinition.csv
- layout/subscribeWidgetdef.csv
- layout/layout.csv
- layout/layoutWidgetRelationship.csv
- layout/widgetnvp.csv
- Open the output CSV files to review the file contents.
- Verify that the file contents match the data in the database for the layouts that belong to the specified store.
What to do next
We can load your extracted data into another WebSphere Commerce instance with the Data Load utility. For a sample that demonstrates how to load layout data, see Sample: Loading Commerce Composer layouts. When you follow this sample, edit the load order configuration file to specify the CSV files that were generated by the Data Extract utility.
Related concepts
Overview of the Data Extract utility