To support hierarchical searching on the product catalog, each category and product has a property called ancestorCategories, whose value is a Set of categories that are higher in the catalog hierarchy than the given catalog or product.

Note: The data for the ancestorCategories property must be updated whenever new categories or products are added to or deleted from the product catalog or when an existing category is modified to contain a different set of products or child categories. To update the data for the ancestorCategories property, use the Nucleus component AncestorGeneratorService:

The generateAncestors method automatically updates the ancestorCategories property for every product and category in the catalog. A message is displayed indicating that the method ran successfully.

Note that the Methods tab also includes methods called generateCategoryAncestors (which generates the ancestorCategories property for category items only) and generateProductAncestors (which generates the ancestorCategories property for product items only). The generateAncestors method works by calling both of these methods.

You should regenerate the ancestor categories whenever the set of products or categories in the catalog changes. Generating ancestor categories can be time-consuming. Run the AncestorGeneratorService only on the staging database, not the live database.

By default, the AncestorGeneratorService component is configured to work with the standard catalog schema. It generates ancestor categories for the product and category item types, and stores the names of these ancestor categories in the ancestorCategories property of each product and category.

If you are using a different schema, you can still use AncestorGeneratorService to generate ancestor categories, provided that:

The GenerateAncestorService generates ancestors for all categories, then ancestors for all products. This minimizes writing to the database; the service only needs to find the immediate category ancestor for any product, since the further ancestors of the category have already been determined.

 
loading table of contents...