getProductSearchResults method
- String widgetId,
- int accountId,
- String brUid2,
- String domainKey,
- String imageId,
- String url, {
- String? authKey,
- String? fields = "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",
- int? rows = 10,
- int? objectId,
- String? filter,
Returns product data and attriutes based on inputted query structure. Queries can also include filters and facets.
Parameters:
-
String widgetId (required): The ID of the widget, which can be found in the Widget Configurator in the Dashboard.
-
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 imageId (required): You’ll get this value in the Upload API response once an image is uploaded. You can use image_id to make any number of subsequent queries for widget responses (with different parameters/filters and objects) without the need to re-upload.
-
String url (required): The absolute URL of the page where the request is initiated. Do not use a relative URL.
-
String fields: A comma-separated list of fields to be sent in the request. Alternatively, you may configure the fields in the Widget Configurator in the Dashboard instead. This parameter is required if not sent via the Dashboard.
-
int rows: he number of matching items to return per results page in the API response. The maximum value is 200. The result size is used from the Dashboard if it is not sent in the API. To enhance performance, limit this value to the number of items that you think is reasonable for a single page of search results.
-
int objectId: By default, you will get the recommendations for the whole image you uploaded if you make an API call without the object_id
denoted by -1
. To get more targeted results, you can also make API calls specific to object_ids. -
String filter: The filter parameter applies a faceted filter to the returned products, searching for products that fit your parameter values. Any facet that you want to filter must be in your feed. Attributes must be enabled and mapped by Bloomreach. Let your Bloomreach representative know which attributes in your content feed you want to apply as filters to search results. You can filter results based on numeric ranges.
Implementation
Future<VisualSearchResponse?> getProductSearchResults(
String widgetId,
int accountId,
String brUid2,
String domainKey,
String imageId,
String url, {
String? authKey,
String? fields = "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",
int? rows = 10,
int? objectId,
String? filter,
}) async {
final response = await getProductSearchResultsWithHttpInfo(
widgetId,
accountId,
brUid2,
domainKey,
imageId,
url,
authKey: authKey,
fields: fields,
rows: rows,
objectId: objectId,
filter: filter,
);
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),
'VisualSearchResponse',
) as VisualSearchResponse;
}
return null;
}