Sample: Loading Commerce Composer pages
This sample demonstrates how to load Commerce Composer pages for use in the Commerce Composer tool and on the storefront.Before beginning
This sample requires a published store that is based on the Aurora starter 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
To create a Commerce Composer page, we must use the Data Load utility to load information about the page and register the page within the WebSphere Commerce database. With the Data Load utility, we can also load information that associates a page with a page group. We must associate a page with a page group before a Management Center user can manage the page with the Commerce Composer tool.
The following sample loads information about two Commerce Composer pages and associates a page with a page group. The sample loads a sample help page and home page, SEO information for both pages, and associates the home page with a page group. The sample also loads information to assign a specific layout to the sample home page. 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/page
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\page
If we are using this sample to help us create Commerce Composer pages that exist in another instance, we can use the Data Extract utility to generate the input files for loading your page data. We can use the Data Extract utility to extract the existing page 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 page data, see Sample: Extracting Commerce Composer pages.
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
- page.csv
XML
- page.xml
For more information about the type of data within the input file, see page input file
This sample input file loads page information that creates sample content pages. Management Center users can manage the pages with the Commerce Composer tool.
The Data Load utility loads the information in the input file into the PLPAGE 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.PageMediator Business object configuration file
- (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-page.xml
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-page.xml
CSV
- layoutAssignment.csv
XML
- layoutAssignment.xml
For more information about the type of data within the input file, see layoutAssignment input file
The Data Load utility uses this sample input file to load information that assigns layouts to one or more pages.
The Data Load utility loads the information in the input file into the EMSPOT, DMACTIVITY, DMELEMENT, DMELEMENTNVP, DMTRIGLSTN, and PLLOCATION 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.LayoutAssignmentMediator Business object configuration file
- (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-layoutAssignment.xml
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-layoutAssignment.xml
CSV
- seopage.csv
XML
- seopage.xml
For more information about the type of data within the input file, see seopage input file
This sample input file loads custom search engine optimization (SEO) properties for a content page.
The Data Load utility loads the information in the input file into the SEOURL, SEOURLKEYWORD, SEOPAGEDEF, SEOPAGEDEFDESC, SEOPAGEDEFOVR, SEOREDIRECT 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.SeoPageMediator Business object configuration file
- (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-seopage.xml
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-seopage.xml
This sample loads SEO information for a page in a single language. For more information about loading sample SEO information in multiple languages, see Sample: Loading Commerce Composer page SEO information in multiple languages.
CSV
- seopagedesc.csv
XML
- seopagedesc.xml
For more information about the type of data within the input file, see seopage input file
This sample input file loads custom search engine optimization (SEO) descriptive information for a content page.
The Data Load utility loads the information in the input file into the SEOURL, SEOURLKEYWORD, SEOPAGEDEF, SEOPAGEDEFDESC, SEOPAGEDEFOVR, SEOREDIRECT 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.SeoPageDescMediator Business object configuration file
- (Linux) utilities_root/samples/DataLoad/CommerceComposer/wc-loader-seopagedesc.xml
(Developer) WCDE_installdir\samples\DataLoad\CommerceComposer\wc-loader-seopagedesc.xml
For more information about business object configuration files, see Configure the business object configuration file.
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 for a Commerce Composer page and load the information for this sample:
- (Linux) ./dataload.sh ../samples/DataLoad/CommerceComposer/page/wc-dataload-page.xml
(Developer) dataload ..\samples\DataLoad\CommerceComposer\page\wc-dataload-page.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 page 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 PLPAGE where ADMINNAME like 'Sample%'; select * from EMSPOT where NAME = 'Content_' || (select CAST (CAST(PLPAGE_ID AS CHAR(50)) AS VARCHAR(50)) from PLPAGE where ADMINNAME = 'SampleHomePage'); select * from DMACTIVITY where DMACTIVITY_ID in (select DMACTIVITY_ID from PLLOCATION where PAGELAYOUT_ID in ( select PAGELAYOUT_ID from PAGELAYOUT where NAME like 'Sample%')); select * from DMELEMENT where DMACTIVITY_ID IN (select DMACTIVITY_ID from PLLOCATION where PAGELAYOUT_ID in ( select PAGELAYOUT_ID from PAGELAYOUT where NAME like 'Sample%' )); select * from DMELEMENTNVP where DMELEMENT_ID in (select DMELEMENT_ID from DMELEMENT where DMACTIVITY_ID IN (select DMACTIVITY_ID from PLLOCATION where PAGELAYOUT_ID in ( select PAGELAYOUT_ID from PAGELAYOUT where NAME like 'Sample%' ))); select * from PLLOCATION where PAGELAYOUT_ID in ( select PAGELAYOUT_ID from pagelayout where NAME like 'Sample%' ) order by DMACTIVITY_ID; select * from DMTRIGLSTN where DMELEMENT_ID in (select DMELEMENT_ID from DMELEMENT where DMACTIVITY_ID IN (select DMACTIVITY_ID from PLLOCATION where PAGELAYOUT_ID in ( select PAGELAYOUT_ID from PAGELAYOUT where NAME like 'Sample%' ))); select * from SEOPAGEDEF where PAGENAME in ('Content_' || (select CAST (CAST(plpage_id AS CHAR(50)) AS VARCHAR(50)) from plpage where adminname = 'SampleHomePage'), 'Content_' || (select CAST (CAST(plpage_id AS CHAR(50)) AS VARCHAR(50)) from PLPAGE where ADMINNAME = 'SampleHelpPage')); select * from SEOPAGEDEFDESC where SEOPAGEDEF_ID in ( select SEOPAGEDEF_ID from SEOPAGEDEF where PAGENAME in ('Content_' || (select CAST (CAST(PLPAGE_ID AS CHAR(50)) AS VARCHAR(50)) from plpage where adminname = 'SampleHomePage'), 'Content_' || (select CAST (CAST(PLPAGE_ID AS CHAR(50)) AS VARCHAR(50)) from PLPAGE where ADMINNAME = 'SampleHelpPage'))); select * from SEOPAGEDEFOVR where SEOPAGEDEF_ID in ( select SEOPAGEDEF_ID from SEOPAGEDEF where PAGENAME in ('Content_' || (select CAST (CAST(PLPAGE_ID AS CHAR(50)) AS VARCHAR(50)) from plpage where adminname = 'SampleHomePage'), 'Content_' || (select CAST (CAST(PLPAGE_ID AS CHAR(50)) AS VARCHAR(50)) from PLPAGE where ADMINNAME = 'SampleHelpPage'))); select * from SEOREDIRECT; select * from SEOURL where TOKENNAME='StaticPagesToken' and TOKENVALUE in ( select CAST(PLPAGE_ID AS CHAR(50)) from PLPAGE where ADMINNAME like 'Sample%'); select * from SEOURLKEYWORD where SEOURL_ID in ( select SEOURL_ID from SEOURL where TOKENNAME='StaticPagesToken' and TOKENVALUE in ( select CAST(PLPAGE_ID AS CHAR(50)) from PLPAGE where ADMINNAME like 'Sample%') );Ensure that the data within the sample input files exists within the appropriate database tables.
In Management Center, verify that users can see the pages in the Commerce Composer tool by viewing the list of available layouts. Ensure that the layout assignment and search term assignment you loaded are in the Layouts - Layout List grid. The following image shows the new assignments.
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 an SQL file to remove the data for this sample.
(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.- Open the Cleanup.sql for editing. Replace the contents of this file with the following SQL.
delete from seourl where SEOURL_ID in (select SEOURL_ID from SEOURLKEYWORD where URLKEYWORD = 'sampleHelp'); delete from seopagedef where pagename = 'Content_' || (select CAST(plpage_id AS VARCHAR(50)) from plpage where adminname = 'SampleHelpPage'); delete from seopagedef where pagename = 'Content_' || (select CAST(plpage_id AS VARCHAR(50)) from plpage where adminname = 'SampleHomePage'); delete from plpage where adminName in ('SampleHelpPage', 'SampleHomePage');
- Save and close the file.
- From a command prompt, connect to the database with your user ID and password. Run the following command to remove the data from the database: (DB2)
- (Linux) db2 -tvf ../samples/DataLoad/CommerceComposer/page/Cleanup.sql
(Oracle)
- (Linux) sqlplus user_name/password@ database_name@ ../samples/DataLoad/CommerceComposer/page/Cleanup.sql