Load promotion folders and promotions into promotion folders

This sample demonstrates how to load promotion folders and promotion data to create folders and sort promotions into their corresponding folders. After you load the data, Management Center users can view the folders and sorted promotions in the Promotions tool.

To help business users organize the promotions for a store, promotion folders are available in the Promotions tool. For more information about Management Center folders, see
Folders.


About this sample

When you run the Data Load utility to load this sample, the load operation first creates promotion folders for use in Management Center. Then, the load operation creates relationships between promotions and the folders that the promotions are going to be added within. The promotions are sorted based on the starting date time stamp of the promotions. This time stamp is retrieved from the STARTDATE column in the PX_PROMOTION database table. After the load operation completes, we can view the folders in the Promotions tool and browse through the folders to locate the promotions.

If you plan to create many promotion folders for the store or sort many promotions into folders, use the Data Load utility to create the folders and folder relationships. Copy the files provided with this sample and modify the files to help us create the input and configuration files for loading the store-specific data. If the store contains many promotions, we can create Java programs to generate the input files for creating the store promotion folders and for sorting promotions into these folders. See Java classes for generating data load input files for promotion folders and folder relationships. We can load data for promotion folders and folder relationships in CSV or XML formatted input files. The following procedure loads the CSV input files. The sample CSV input files and data load configuration files for this sample are in the following directory:

As an administrator, we can configure the Promotions tool so that only promotions that are not in a folder display in the main Promotions - List view. If the store has hundreds or thousands of promotions, preventing promotions that are sorted in folders from displaying in the Promotions - List view can make finding promotions easier. With this configuration enabled, business users can browse through folders to find sorted promotions and browse the main Promotions - List view to find unsorted promotions. For more information, see Organizing promotions with folders.


Sample input and configuration files

The following table lists the input files that we use to load the sample data. 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 CSV input file Description
PromotionFolders.csv

For more information about folder data, see Promotion folder input file

The Data Load utility uses this sample input file to load the data to create promotion folders in the Promotions tool.

The Data Load utility uses the following business object mediator and business object configuration file to load the data in this input file into the FOLDER database table.

Business object mediator

com.ibm.commerce.foundation.dataload.businessobjectbuilder.TableObjectBuilder Sample business object configuration file for loading this information:

  • (Linux) utilities_root/samples/DataLoad/Promotion/Folder/wc-loader-promotion-folder.xml

  • (Developer) WCDE_installdir\samples\DataLoad\Promotion\Folder\wc-loader-promotion-folder.xml

PromotionFolderItems.csv

For more information about the data to sort promotions into promotion folders, see Promotion folder relationship input file

The Data Load utility uses this sample input file to sort promotions that exist in the main Promotions List in the Promotions tool into newly created promotion folders.

The Data Load utility uses the following business object mediator and business object configuration file to load the data in this input file into the FOLDERITEM database table.

Business object mediator

com.ibm.commerce.foundation.dataload.businessobjectbuilder.TableObjectBuilder Sample business object configuration file for loading this information:

  • (Linux) utilities_root/samples/DataLoad/Promotion/Folder/wc-loader-promotion-folderitem.xml

  • (Developer) WCDE_installdir\samples\DataLoad\Promotion/Folder\wc-loader-promotion-folderitem.xml

Note: This sample PromotionFolderItems.csv file contains promotion ID values that might not exist for the promotions in the store. Before you load this CSV input file, ensure that you update the input file to include ID values that exist for promotions in the store. The promotion ID values for promotions are stored in the PX_PROMOTION_ID column of the PX_PROMOTION database table.

The sample directory also includes the following Data Load utility configuration files:


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 and load the information that included in this sample:

    • (Linux) ./dataload.sh ../samples/DataLoad/Promotion/Folder/wc-dataload.xml

    • (Developer) dataload ..\samples\DataLoad\Promotion\Folder\wc-dataload.xml


Verifying results


Removing the sample data from the WebSphere Commerce database

Edit the wc-dataload.xml load order configuration file to change the value of the dataLoadMode attribute from "Replace" to "Delete" to run the Data Load utility in delete mode. When you run the utility in delete mode, the utility deletes the data in the database that matches the rows in your CSV file. You do not need to edit the value for the Delete column in your input CSV file. Verify that the data is removed from the database by running the following SQL statements:

The data that you loaded with this sample should no longer exist in the database.

In Management Center, verify that we can no longer view the promotion folders and the appropriate promotions in the folders in the Promotions tool.