Feature Pack 4Feature Pack 2Feature Pack 3Feature Pack 1

Sample: Loading attachment relationships for categories and catalog entries

This sample demonstrates how to associate attachments, specifically image attachments, with 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.
The Data Load utility direct table load function is used to create the relationships between the categories, catalog entries, and attachments usages.
Note: Attachments are not created. The attachments must exist in your environment before you can associate the attachments with with catalog entries or categories.
This sample loads the following types of input files:

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
    You can create these managed files by uploading the images in a compressed (.zip) file with the file loader utility or 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

  1. Open the command-line interface and navigate to the appropriate directory:
    • WC_installdir/bin
    • WebSphere Commerce DeveloperWCDE_installdir\bin
  2. Enter the following command:
    For a non-ATP store:Feature Pack 4Feature Pack 2Feature Pack 3Feature Pack 1
    • SolarisLinuxAIX./dataload.sh ../samples/DataLoad/Catalog/Attachment/wc-dataload.xml
    • Windowsdataload.bat ..\samples\DataLoad\Catalog\Attachment\wc-dataload.xml
    • WebSphere Commerce Developerdataload ..\samples\DataLoad\Catalog\Attachment\wc-dataload.xml
    For an ATP store:
    • SolarisLinuxAIX./dataload.sh ../samples/DataLoad/Catalog/Attachment/wc-dataload-ATP.xml
    • WebSphere Commerce DeveloperWindowsdataload ../samples/DataLoad/Catalog/Attachment/wc-dataload-ATP.xml
    The command performs the following steps:
    1. Loads catalog groups from the CatalogGroup.csv file.
    2. Loads catalog entries from CatalogEntries.csv file.
    3. Loads the catalog group to attachment relationship from the CatalogGroupAttachment.csv file.
    4. 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:
    <_config:Column name="ATCHRLUS_ID" value="1" valueFrom="Fixed" />
    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.

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:
    • SolarisLinuxAIXWC_installdir/samples/DataLoad/Catalog/Attachment/CleanUp.sql
    • WindowsWC_installdir\samples\DataLoad\Catalog\Attachment\CleanUp.sql
    • WebSphere Commerce DeveloperWCDE_installdir\samples\DataLoad\Catalog\Attachment\CleanUp.sql
  • To remove the files, see Deleting managed files.
  • To remove the attachments, see Deleting attachments.