Sample: Loading attachment relationships for categories and catalog entries
About this sample
With this sample, the Data Load utility loads data to create the following objects:- Categories and relationships between categories and attachments.
- Catalog entries and relationships between the catalog entries and attachments.
Before you begin
Before you can add attachments to a catalog entry or category, the attachments must exist in your database. Ensure that you create the managed files and attachments that you are adding to a catalog entry or category. Ensure that you create the following managed files, attachments, and attachment assets:- Managed files
- samples\DataLoad\Catalog\Attachment\mens_pants_dress.gif
- samples\DataLoad\Catalog\Attachment\mens_pants_cords_sm.gif
- samples\DataLoad\Catalog\Attachment\mens_pants_cords.gif
- Create the managed files with the fileloader utility.
- Create the managed files with the Management Center Assets tool.
Note: You must copy the three .gif files on the server to your local machine before you can upload these files. - Attachments and attachment assets
Attachment Attachment asset (managed file) Category Pants full image mens_pants_dress.gif SKU Cords-Black-29W x 28L small image mens_pants_cords_sm.gif SKU Cords-Brown-29W x 28L full image mens_pants_cords.gif For more information about creating these attachments and associating the assets to the attachments, see Creating attachments. When you load this sample, the category and catalog entries that are created are associated with the attachments that you created.
Procedure
- Open the command-line interface and navigate to the appropriate directory:
- WC_installdir/bin
- WCDE_installdir\bin
- Enter the following command:For a non-ATP store:
- ./dataload.sh ../samples/DataLoad/Catalog/Attachment/wc-dataload.xml
- dataload.bat ..\samples\DataLoad\Catalog\Attachment\wc-dataload.xml
- dataload ..\samples\DataLoad\Catalog\Attachment\wc-dataload.xml
For an ATP store:- ./dataload.sh ../samples/DataLoad/Catalog/Attachment/wc-dataload-ATP.xml
- dataload ../samples/DataLoad/Catalog/Attachment/wc-dataload-ATP.xml
The command performs the following steps:- Loads catalog groups from the CatalogGroup.csv file.
- Loads catalog entries from CatalogEntries.csv file.
- Loads the catalog group to attachment relationship from the CatalogGroupAttachment.csv file.
- Loads the catalog entry to attachment relationship from the CatalogEntryAttachment.csv file.
Note: In the wc-loader-catalogGroupAttachment.xml and wc-loader-catalogEntryAttachment.xml configuration files, the following line specifies the attachment usage:
An image attachment has a value of 1. You can change the value to specify a different usage if needed, for example value="102" for a warranty document.<_config:Column name="ATCHRLUS_ID" value="1" valueFrom="Fixed" />
Verifying results
Verify that the data is loaded by running the following SQL statements:select * from catgroup where identifier in ('Mens Fashions','Womens Fashions','Pants','Shirts','Activewear', 'Accessory');
This SQL statement returns all catalog groups that are loaded in this sample.
select * from catentry where partnumber like 'Cords%';
This SQL statement returns all catalog entries that are loaded in this sample.
select * from atchrel where ATCHOBJTYP_ID=2 and atchtgt_id in (select atchtgt_id from atchtgt where identifier in ('Category Pants full image','Category Pants small image'));
This SQL statement returns one catalog group to attachment relationship.
select * from atchrel where ATCHOBJTYP_ID=3 and atchtgt_id in (select atchtgt_id from atchtgt where identifier in ('SKU Cords-Black-29W x 28L small image','SKU Cords-Brown-29W x 28L full image'));
This SQL statement returns two catalog entry to attachment relationships.
Verify that the relationships exist in the Catalogs tool. Open the Catalogs tool and browse the categories and catalog entries that are created in this sample. Ensure that you see the attachments that you associated with the categories or catalog entries.
Verify that the relationships exist in the storefront. Go to the storefront and browse to the created categories and SKUs and ensure that you can see the associated image attachments.
Cleaning up the data
- To delete the data that is loaded in this sample, run the following SQL file:
- WC_installdir/samples/DataLoad/Catalog/Attachment/CleanUp.sql
- WC_installdir\samples\DataLoad\Catalog\Attachment\CleanUp.sql
- WCDE_installdir\samples\DataLoad\Catalog\Attachment\CleanUp.sql
- To remove the files, see Deleting managed files.
- To remove the attachments, see Deleting attachments.