While querying fredhopper to get the resultset, I have seen that there is 2 methods available to get the list of items from query resultset, getItems() and getPromotions(). Can anyone explain what is the List received as a part of execution result of getItems() method. When I used item.getRegion() method it always return null. Thanks in advance..
1 Answer
Promotions are the SmartTarget promotions that match your query. They apply for certain regions (getRegion, singular, is deprecated at least in SmartTarget 2014 SP1).
The docs explain result set...
Represents the result of a query to Fredhopper.
Includes Promotions, Items (search results) and a Navigational structure based on Fredhopper's facets. Example:
QueryBuilder
QueryBuilder queryBuilder = new QueryBuilder(publicationId, regionList);
ResultSet resultSet = queryBuilder.execute();
int totalItemCount = resultSet.getItemsTotalCount();
List<Promotion> promotions = resultSet.getPromotions();
List<Item> items = resultSet.getItems();
Navigation navigation = resultSet.getNavigation();
Items from a result set are search results, which seem to be the same type of object, but separate from the items inside the Promotions.
If placing SmartTarget Promotions, I think you'd use getRegions()
and supportsRegion(String regionName)
to place them, but I'll let the devs confirm the right approach.
-
Thanks Alvin, from above answer may I assume that getItems() return all the items which is not part of any promotions and may be because of that getRegions() for these items are always null. It it correct? Jul 26, 2015 at 17:01
-
Yes on the "not part of promotions" part. I'm not sure why getRegions() is null for them. Maybe items returned for search don't have regions? For comparison, check if the items in the promotions have regions as well. Jul 27, 2015 at 3:44
-
1This is only because some components published are normal dynamic component and not a part of any promotion. So they are not directly linked to any region. Only promotion items are linked to regions. Thanks.. Jul 27, 2015 at 4:09