Samples > Data load utility samples
Sample: Changing the parent of a subcategory
This sample demonstrates how to use the CatalogGroupRelationshipMediator data load mediator to move a subcategory from one parent to another.
About this sample
In this sample, the mediator deletes the parent relationship between the "Women's fashions" top category and "Accessories" subcategory. In the same operation, the mediator creates a new parent relationship, making "Accessories" a subcategory of the "Men's fashions" top category.
Procedure
- Open the command-line interface, and navigate to the appropriate directory:
- WC_INSTALL/bin
- WCDE_INSTALL\bin
- Enter the following command:
- ./dataload.sh ../samples/DataLoad/Catalog/ChangeParent/wc-dataload.xml
- dataload ..\samples\DataLoad\Catalog\ChangeParent\wc-dataload.xml
Verify results
The wc-dataload.xml configuration file first calls the wc-loader-catalog-group.xml configuration file to load all sample categories from the CatalogGroups.csv source file in parent directory. Next the wc-dataload.xml file calls the wc-loader-catalog-group-relationship.xml configuration file to change the parent of category "Accessory" from "Women's Fashions" to "Men's Fashions" using the ChangeCatalogGroupParent.csv source file.Verify that the parent category has been changed by running the following SQL statements:
- To return the subcategories of the "Men's Fashions" category, enter:
select * from catgrprel where catgroup_id_child=(select catgroup_id from catgroup where identifier='Accessory') and catgroup_id_parent=(select catgroup_id from catgroup where identifier='Mens Fashions')
- To return the subcategories of the "Women's Fashions" category, enter:
select * from catgrprel where catgroup_id_child=(select catgroup_id from catgroup where identifier='Accessory') and catgroup_id_parent=(select catgroup_id from catgroup where identifier='Womens Fashions')
A result of 0 rows indicates that "Accessories" is not a subcategory of "Women's fashions"
You can also verify the load by viewing the categories in the Management Center or in the storefront.
Clean up the data
To remove the data loaded in this sample from the database, run the CleanUp.sql file in the /samples/DataLoad/Catalog/ChangeParent directory.
Previous topic: Sample: Loading classic attributes, attribute values, and allowed values
Next topic: Sample: Loading category descriptions in multiple languages
Related reference