getProductSearchResults method
- int accountId,
- String brUid2,
- String domainKey,
- String q,
- SearchType searchType,
- int start,
- int rows,
- String url,
- String refUrl, {
- String requestType = "search",
- String authKey = "",
- String fl = "pid,title,brand,price,sale_price,thumb_image,sku_thumb_images,sku_swatch_images,sku_color_group,url,price_range,sale_price_range,description,is_live,score,skuid,group",
- String? requestId,
- String? callback,
- String? efq,
- String? facetPeriodRange,
- String? fq,
- String? ll,
- String? sort,
- String? statsPeriodField,
- String? userId,
- String? viewId,
- String? widgetId,
Returns product data and attriutes based on inputted query structure. Queries can also include filters and facets.
Parameters:
-
int accountId (required): Your site's numerical Bloomreach account ID. Your Bloomreach representative gives your site's account ID to you before or during your integration kickoff meeting.
-
String authKey (required): The Bloomreach-provided authentication key for the Bloomreach account that's sending the request.
-
String brUid2 (required): A first-party cookie created by the Bloomreach tracking pixel library (BrTrk). This cookie creates a unique, anonymous identifier for every browser or device.
-
String domainKey (required): Site domain ID which is provided by Bloomreach
-
String fl (required): Filtered list of attributes you want returned in your API response (i.e. productID, price). Multiplevalues should be comma separated)
-
String q (required): Your site visitor's partial search query that Autosuggest should operate on. You can percent encode spaces between terms as %20, or you can leave the spaces unencoded.
-
String requestId (required): An ID to track site visitor clicks. We recommend that you generate unique, random values of 13 digits to enable click-tracking.
-
String requestType (required): The type of API request. Value should be suggest for Autosuggest requests.
-
String searchType (required): The type of search. Value should be keyword for Product Search requests, category for Category requests.
-
int start (required): The number of the first item on a page of results. For example, the first item on the first page is 0, making the start value also 0. The maximum value is 10000.
-
int rows (required): The number of matching items to return per results page in the API response. The maximum value is 200.
-
String url (required): The URL of the page or HTTP referrer where the request is started.
-
String refUrl (required): The URL of the page or HTTP referrer where the request is started.
-
String callback: Indicates whether to return data wrapped in the function for cross-origin requests.
-
String efq: Extends the filtered query and applies a complex boolean filter to search results to include or exclude items that fit your parameter values. Any product attribute in your product feed is valid, such as brand names and sizes.
-
String facetPeriodRange: Return a count of ranged facets, such as price and sale price. Use numeric attributes only. You need to parse the values that are in the facets_counts section of the response.
-
String fq: The fq parameter applies a faceted filter to the returned products, searching for products that fit your parameter values. Use fq=store_lat_lon to enable filtering by distance for BOPIS.
-
String ll: The latitude-longitude of the end-customer used for the Buy Online Pick-up In Store (BOPIS) feature. Value should be provided as latitude,longitude. For example, ll=11.09,10.018.
-
String sort: Sorts results based on the field value in ascending, descending, or another combination of orders. You can sort any fl field. Value is a field name, followed by asc/desc for ascending/descending order respectively.
-
String statsPeriodField: This parameter allows you to display the maximum and minimum values of any numeric field in your data set for a user query. With this parameter, you can get all the documents matching a query and display the minimum and maximum values of single-valued, numeric attributes such as price, sale_price, length, width, reviews, etc.
-
String userId: The universal customer ID of the user. You only need to pass this field if your particular integration tracks customers this way. The parameter captures user IDs from the customer side, and reuses the information when powering apps or enhancing cross-device linking. In this way, Bloomreach recognizes users in a way that's aligned with your system. Use an anonymous string. Don't use email or other personally identifiable information. If you do not track users this way, then omit this field.
-
String viewId: A unique identifier for a specific view of your product catalog. If you have multiple versions of your site, each with their own product catalog characteristics like product titles and prices, then add view_id to your call. Bloomreach uses your view_id parameter value to display the right product information for your customers based on their individual site views. You can enter any string value to identify the specific site catalog view. This string must be consistent in your pixel, API, and product catalog.
-
String widgetId: The widget_id provided in the Dashboard for the Dynamic Widgets feature, which is used to provided curated results.This is an optional feature that can be enabled by discussing with your CSM.
Implementation
Future<ProductSearchResponse?> getProductSearchResults(
int accountId,
String brUid2,
String domainKey,
String q,
SearchType searchType,
int start,
int rows,
String url,
String refUrl, {
String requestType = "search",
String authKey = "",
String fl =
"pid,title,brand,price,sale_price,thumb_image,sku_thumb_images,sku_swatch_images,sku_color_group,url,price_range,sale_price_range,description,is_live,score,skuid,group",
String? requestId,
String? callback,
String? efq,
String? facetPeriodRange,
String? fq,
String? ll,
String? sort,
String? statsPeriodField,
String? userId,
String? viewId,
String? widgetId,
}) async {
final response = await getProductSearchResultsWithHttpInfo(
accountId,
authKey,
brUid2,
domainKey,
fl,
q,
requestId != null ? requestId : generateRequestId().toString(),
requestType,
searchType == SearchType.KEYWORD ? "keyword" : "category",
start,
rows,
url,
refUrl,
callback: callback,
efq: efq,
facetPeriodRange: facetPeriodRange,
fq: fq,
ll: ll,
sort: sort,
statsPeriodField: statsPeriodField,
userId: userId,
viewId: viewId,
widgetId: widgetId,
);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty &&
response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(
await _decodeBodyBytes(response),
'ProductSearchResponse',
) as ProductSearchResponse;
}
return null;
}