Sample: Loading Commerce Composer widgets

This sample demonstrates how to load Commerce Composer widget information to register a widget and subscribe a store to a widget. After you register and subscribe a widget with the Data Load utility, Management Center users can use the widget to design store pages with the Commerce Composer tool.

Note: This sample loads sample Commerce Composer widgets as well as a sample layout template and layout.

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:


About this sample

When we are creating a Commerce Composer widget, in addition to the storefront assets that we must create, we must use the Data Load utility to load and register the definition information for the widget. We must also load the relationship between the widget and a store to subscribe the store to use the widget. A store must subscribe to a widget for that widget to be available for users to include on a page for that store. The following sample loads the information needed to register a widget and have a store subscribe to the widget. When you load this information, you create two widgets, a Sample site widget and a Sample store widget. This sample, however, does not create the storefront or Management Center definition for the widget. For more information about creating a widget, see Creating Commerce Composer widgets. We can load this sample information in both CSV or XML formatted input files. The following procedure, however, loads only CSV input files. If you prefer to work with the data within the XML formatted files, we can create the XML files and edit the sample configuration files to load the XML files. The sample CSV input files are located within the following directory:

This sample also loads input files included as part of the samples for loading Commerce Composer layout templates. The input files for loading layout templates are located within the following directory:

For more information about WebSphere Commerce the sample for loading Commerce Composer layout templates, see Sample: Loading Commerce Composer layout templates.

If we are using this sample to help you create Commerce Composer widgets that exist 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 and subscription 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.

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

  • registerWidgetdef.csv

XML

  • registerWidgetdef.xml

For more information about the data included in this file, see registerWidgetdef input file

The Data Load utility uses this sample input file to load information that registers layout template containers and widgets within the WebSphere Commerce database and Commerce Composer framework. This sample loads two registerWidgetdef.csv input files:

  • The registerWidgetdef.csv file within the widget directory loads the information to register widgets.

  • The registerWidgetdef.csv file within the template directory loads the information to register template containers for a template. The registerWidgetdef.csv that loads template container information is also loaded as part of the sample for loading a Commerce Composer layout template.

The order that the Data Load utility loads the information within these input files is defined within the wc-dataload-widget.xml load order configuration file. The registerWidgetdef.csv file within the template loads before the file within the widget directory.

The Data Load utility loads the information within these 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 these input files:

Business object mediator

com.ibm.commerce.pagelayout.dataload.mediator.registerWidgetdefMediator Sample business object configuration file for loading this information:

  • (Linux) utilities_root/samples/DataLoad/PageComposer/wc-loader-registerWidgetdef.xml

  • (Developer) WCDE_installdir\samples\DataLoad\PageComposer\wc-loader-registerWidgetdef.xml

CSV

  • subscribeWidgetdef.csv

XML

  • subscribeWidgetdef.xml

For more information about the data that can be included in this file, see subscribeWidgetdef input file

After the Data Load utility loads the information to register the widgets and containers, the utility loads two subscribeWidgetdef.csv files to subscribe the widgets and containers to a store. A store must subscribe to specific widgets and containers so that these objects can be used in the Commerce Composer tool for that store. This sample loads two subscribeWidgetdef.csv files:

  • The subscribeWidgetdef.csv file within the widget directory loads the information to subscribe widgets to a store.

  • The subscribeWidgetdef.csv file within the template directory loads the information to subscribe a layout template to a store. This subscribeWidgetdef.csv file is also loaded as part of the sample for loading a Commerce Composer layout template.

The order that the Data Load utility loads the information within these input files is defined within the wc-dataload-widget.xml load order configuration file. The subscribeWidgetdef.csv file within the template loads before the file within the widget directory.

The Data Load utility loads the information within these input files into the PLSTOREWIDGET database table. 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.SubscribeWidgetDefinitionMediator Business object configuration file

  • (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-subscribeWidgetdef.xml

  • (Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-subscribeWidgetdef.xml

CSV

  • template.csv

XML

  • template.xml

For more information about the data included in this file, see template input file

This input file loads information to create the relationship between template containers and a template. This file is also loaded as part of the sample for loading a Commerce Composer layout template.

The Data Load utility loads the information within the input file into the PAGELAYOUT database table. 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.WidgetMediator Business object configuration file

  • (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-template.xml

  • (Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-template.xml

CSV

  • slotDefinition.csv

XML

  • slotDefinition.xml

For more information about the data included in this file, see slotDefinition input file

This input file loads information to define the slots within a container for a template. Each slot is defined with x and y coordinates. Management Center uses this information to draw the wireframe for the template within the Commerce Composer tool.

The Data Load utility loads the information within the input file into the PLWIDGETSLOT database table. 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.WidgetSlotsMediator Business object configuration file

  • (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-widgetslot.xml

  • (Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-widgetslot.xml

CSV

  • layout.csv

XML

  • layout.xml

For more information about the data included in this file, see layout input file

The Data Load utility loads this input file to load layout information into a store so that Management Center users can use the layouts in the Commerce Composer tool.

The Data Load utility loads the information within the input file into the PAGELAYOUT, and PLTEMPLATEREL 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.LayoutMediator Business object configuration file

  • (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-pagelayout.xml

  • (Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-pagelayout.xml

CSV

  • layoutWidgetRelationship.csv

XML

  • layoutWidgetRelationship.xml

For more information about the data included in this file, see layoutWidgetRelationship input file

This input file loads information about the relationship between widgets, containers, and a layout. This file loads the information to associate a container and widget with a layout template to create a layout.

The Data Load utility loads the information within the input file into the PLWIDGET, and PLWIDGETREL 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.WidgetMediator Business object configuration file

  • (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-widget.xml

  • (Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-widget.xml

This sample loads widget information for a single language. For more information about loading widget descriptive information in multiple languages, see Sample: Loading Commerce Composer widget descriptive information in multiple languages.


Procedure

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

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

  3. Enter the following command to run the sample data load order file for a Commerce Composer widget and load the information for this sample:

    • (Linux) ./dataload.sh ../samples/DataLoad/CommerceComposer/widget/wc-dataload-widget.xml

    • (Developer) dataload ..\samples\DataLoad\CommerceComposer\widget\wc-dataload-widget.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, see
    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:

Ensure that the data within the sample input files exists within the appropriate database tables.

In Management Center, verify that users can use the widget in the Commerce Composer tool by Creating 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 widgets you loaded are in the Add Widgets to Slots window. The following image shows the Sample site widget and the Sample store widget within 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. Alternatively, we can run the Cleanup.sql file for this data load sample. The Cleanup.sql file is located within the following directory:

From a command prompt, connect to the database with your user ID and password. Run the following command (DB2)

(Oracle)