Note: For custom catalogs, see the Using Custom Catalogs chapter in the ATG Commerce Programming Guide.

If your catalog has a hierarchical structure, you can set up your site so that customers can navigate to products by traversing the catalog hierarchy. The structure of the catalog hierarchy is determined by the child categories and child products of each category. For example, in a grocery store site, the user might get to a product called Oranges by first selecting the Fruit category, then selecting the Citrus Fruit category (which is a child category of Fruit), and then selecting the Oranges product (which is a child product of Citrus Fruit).

To facilitate this type of hierarchical navigation, you can use Dynamo Servlet beans in your catalog pages to display a list of all of the child categories and child products of a category. For example, the grocery store’s Fruit page might list many different fruit products (e.g., Apples, Pears), as well as child categories (e.g., Citrus Fruit). When a user clicks on the name of a product on this page, your site displays that product. When a user clicks on the name of a category, your site displays a list of that category’s child categories and child products.

The following example shows a portion of a JSP that renders the displayName property of each child category and child product of the current category. Each of these values is rendered as a link to the corresponding item. The current category’s repository ID is passed to this page (via the itemId parameter) from the page that links to it:

<dsp:droplet name="/atg/commerce/catalog/CategoryLookup">
<dsp:param param="itemId" name="id"/>

<dsp:oparam name="output">
   <dsp:droplet name="/atg/dynamo/droplet/ForEach">
     <dsp:param param="element.childCategories" name="array"/>
     <dsp:oparam name="outputStart">
     <p><b>Child Categories:</b>
     <ul>
     </dsp:oparam>
     <dsp:oparam name="output">
     <li><dsp:getvalueof id="a24" param="element.template.url"
              idtype="java.lang.String">
<dsp:a href="<%=a24%>">
     <dsp:valueof param="element.displayName"/>
     <dsp:param param="element.repositoryId" name="itemId"/>
     </dsp:a></dsp:getvalueof>
     </dsp:oparam>
     <dsp:oparam name="outputEnd">
     </ul>
     </dsp:oparam>
   </dsp:droplet>

   <dsp:droplet name="/atg/dynamo/droplet/ForEach">
     <dsp:param param="element.childProducts" name="array"/>
     <dsp:oparam name="outputStart">
     <p><b>Child Products:</b>
     <ul>
     </dsp:oparam>
     <dsp:oparam name="output">
     <li><dsp:getvalueof id="a61" param="element.template.url"
              idtype="java.lang.String">
<dsp:a href="<%=a61%>">
     <dsp:valueof param="element.displayName"/>
     <dsp:param param="element.repositoryId" name="itemId"/>
     </dsp:a></dsp:getvalueof>
     </dsp:oparam>
     <dsp:oparam name="outputEnd">
     </ul>
     </dsp:oparam>
   </dsp:droplet>
</dsp:oparam>
</dsp:droplet>
Using a Targeter to find Root Categories

Typically, a catalog home page displays a list of root categories. Unlike other categories, root categories cannot be found through the childCategories property of other categories. To display these categories, ATG Commerce provides a targeter that finds each category whose root property is true.

The following is an example of using the RootCategories targeter in a JSP. This example uses a TargetingForEach servlet bean with the RootCategories targeter to find each category whose root property is true.

<HTML> <HEAD>
<TITLE>Home Page</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<H1>Home Page</H1>
<dsp:droplet name="/atg/targeting/TargetingForEach">
  <dsp:param
       bean="/atg/registry/RepositoryTargeters/ProductCatalog/RootCategories"
       name="targeter"/>

  <dsp:oparam name="output">
  <p><dsp:getvalueof id="a23" param="element.template.url"
                 idtype="java.lang.String">
<dsp:a href="<%=a23%>">
    <dsp:valueof param="element.displayName"/>
    <dsp:param param="element.repositoryId"
                name="itemId"/></dsp:a></dsp:getvalueof>
  </dsp:oparam>
</dsp:droplet>

</BODY> </HTML>
Using the parentCategory Property

A category or product can be the child of more than one category. Specifying multiple parent categories makes the catalog more flexible, but can complicate navigation. This is especially true if the customer accesses a category or product through a search facility rather than by traversing the catalog hierarchy; if the customer then wants to move up the hierarchy, you need to determine which parent category to move to. You can use the parentCategory property of the category and product items to specify a default parent category for this purpose.

For example, suppose you have a link on each page that takes the customer up one level in the catalog hierarchy. If customer views a product that has multiple parent categories, your site can track which parent category the customer accessed the product from, and make this link point back to that category. But if the customer finds the product by searching rather than navigating through the catalog hierarchy, you can have the link point to the category specified by the parentCategory property.

If your catalog uses a different name for this property, set the parentCategoryPropertyName property in the /atg/commerce/catalog/CatalogTools.properties file to the actual name of the property. For example:

parentCategoryPropertyName=higherCategory

CatalogTools uses the parent category property to determine the ancestor categories of a product or category.

 
loading table of contents...