Hello experts!
We're trying to understand the Retail Server API a little better and as a small exercise, we're trying to get all products of a certain category under a certain price.
We were able to get the products belonging to a specific category by using searchByCategoryAsync, but we think it is naive to get All products from a category and do the filtering on the device.
So we tried to find a function that allows us to send filter parameters and have the server answer with the already-filtered information
Currently we think that refineSearchByCategoryAsync is exactly what we're looking for, but we get errors saying that we're not calling the API correctly.
We don't understand the interface - ProductRefinerValue extends SearchRefinerValue that is suggested to us by the IDE, and we tried all kinds of parameter combinations. Does anyone here know how to properly send filter requests to the server?
Here's the interface:
export interface ProductRefinerValue extends SearchRefinerValue { RefinerSourceValue?: number; SwatchImageUrl?: string; SwatchColorHexCode?: string; }
export interface SearchRefinerValue { RefinerRecordId?: number; DataTypeValue?: number; LeftValueBoundString?: string; RightValueBoundString?: string; UnitText?: string; RowNumber?: number; Count?: number; LeftValueBoundLocalizedString?: string; RightValueBoundLocalizedString?: string; ExtensionProperties?: CommerceProperty[]; }
And here's what we're trying right now:
refineSearchByCategoryAsync( { callerContext: this.props.context.actionContext }, this.props.context.request.apiSettings.channelId, this.props.context.request.apiSettings.catalogId, _categoryId,
[
{ // refiner goes here }
])
.then(res => { console.log('refineSearchByCategoryAsync'); res.forEach(product => { console.log(JSON.stringify(product, null, 2)); }); }) .catch(e => console.error('error', e));