Skip to main content
RichRelevance

Android: Category Hints

Overview

Category Hints provide additional category context that may allow additional strategies or merchandising rules. Category Hints can be added to any experience type, even to those who do not accept a Category ID.

Setting category hints can be useful on pages that may have an ambiguous category, such as item pages for items that live in multiple categories. If you don’t set the category context, some strategies will derive category information from the Product ID. In this situation, the context can be set to match the user’s breadcrumbs trail.

Category Hints can be added to any page type, and you can pass multiple category hints in the same personalization request. Each category hint qualifies the page for merchandising rules that are associated to the category.

Details

Place this code after your builder's initialization line.

Placement placement = new Placement(Placement.PlacementType.HOME, "<placement name>");

RichRelevance.buildRecommendationsForPlacements(placement)
  .setCategoryHintIds("mens", "mens-shoes", "sportswear")
  .setCallback(new Callback<PlacementResponseInfo>() {
      @Override
      public void onResult(PlacementResponseInfo result) {          
          int index = 0;
          for(PlacementResponse placement : result.getPlacements()) {
              for(final RecommendedProduct recommendedProduct : placement.getRecommendedProducts()) {
                  // Add your view init logic. The actual implementation will depend on your code.
                  // In this example we will assume items are rendered as TableRows in a TableView.
                  TableRow row = new TableRow(context);
                  row.setId(index);
                  row.addView(detailView);
                  index++;
                  tableView.addLayout(row);
              }
          }
      }
      @Override
      public void onError(Error error) {
          // Use this code block to handle errors
          Log.e(getClass().getSimpleName(), "Error: " + error.getMessage());
      }
  }).execute();
  • Was this article helpful?