Home > widget-integration > FilterAPI > addSortParams
FilterAPI.addSortParams() method
Adds sorting parameters from filter state to API request params.
Extracts the sort value from FilterStore state and includes it in the API request. Override this method to customize sorting behavior, add custom sort options, or implement shop-specific sorting rules.
Signature:
protected addSortParams(params: FilterAPIParams): FilterAPIParams;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
params |
Current filter parameters being built |
Returns:
Enhanced parameters with sort value added if present in state
Remarks
Sort value is only added if it exists in the filter state. If no sort is set, the API will use its default sorting behavior.
Example
Override to add default sorting:
window.boostWidgetIntegration.extend('FilterAPI', (FilterAPI) => {
return class CustomFilterAPI extends FilterAPI {
protected addSortParams(params) {
const enhanced = super.addSortParams(params);
// Add default sort if none specified
if (!enhanced.sort) {
enhanced.sort = 'best-selling';
}
return enhanced;
}
};
});