Sample: Extracting Commerce Composer widgets

This sample demonstrates how to extract Commerce Composer widgets 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 widgets between instances or stores.

A widget, also called a layout widget, is a frame that displays a specific type of store content, such as ads, product recommendations, or navigational links. For more information about widgets, see
Widgets for Commerce Composer.

Before beginning

Ensure that you complete the following tasks:

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 widgets and widget-related data 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 the widgets assigned to layouts for the specified store. The extracted data includes all of the information that you need to register and subscribe the widgets to a store in another WebSphere Commerce instance. This information includes any widget descriptive information that is available for the widgets. This information includes descriptive information that is available in multiple languages. The sample configuration files used to configure the Data Extract utilityare in the following directory and subdirectories:


Sample configuration files

The following configuration files are used to configure the Data Extract utility to extract data into CSV output files.


Procedure

  1. Copy the sample configuration files and directories to a local directory.

  2. 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.

  3. (Developer) On a command line, go to the WCDE_installdir\bin directory.

  4. (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.

  5. Enter the following command to run the sample data extract order configuration for extracting the widget data into CSV output files:

    • (Linux) ./dataextract.sh ../samples/DataExtract/CommerceComposer/wc-dataextract-widget.xml

    • (Developer) dataextract ..\samples\DataExtract\CommerceComposer\wc-dataextract-widget.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 widgets that exist for the configured store ID. These files also include the data for layout templates and any relationship data for widgets assigned to layouts. By default, the files are generated in the following output directory and subdirectories:


Verifying results

  1. Go to the directory that you configured as the output directory. If we did not configure an output directory, go to the following directory:

  2. Verify that the following CSV output files are generated:

    • widget/registerWidgetdef.csv

    • widget/subscribeWidgetdef.csv

    • widget/layout.csv

    • widget/layoutWidgetRelationship.csv

    • widget/MultiLanguages/registerWidgetdefWithMultiLanguages.csv

    • template/registerWidgetdef.csv

    • template/subscribeWidgetdef.csv

    • template/template.csv

    • template/slotDefinition.csv

  3. Open the output CSV files to review the file contents.

  4. 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 widget 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.

To load widget descriptive information in multiple languages, load the information for the default store language first. Then, load the information for multiple languages. We can specify the default language in the environment configuration file business context. By loading the information in the configured default language first, we can reduce the risk of errors during the load operation. For a sample that demonstrates how to load widget descriptive information in multiple languages, see Sample: Loading Commerce Composer page SEO information in multiple languages. When you follow this sample, use the single file approach and edit the load order configuration file to specify the CSV file that was generated by the Data Extract utility.


Related concepts
Overview of the Data Extract utility