Home > widget-integration > FilterService > updateValuesOptions
FilterService.updateValuesOptions() method
Updates option values based on filter settings.
Processes filter options to filter by doc_count, create labels, handle single-option hiding, apply sorting, format rating values, and set appropriate select types. This is the main processing method for transforming raw API options into display-ready options.
Signature:
updateValuesOptions(options: any[], settingOptionValues: any): any[];
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
options |
any[] |
Filter options to update |
|
settingOptionValues |
any |
Settings object controlling option processing |
Returns:
any[]
Updated options array with processed values
Remarks
Applies multiple transformations: - Filters values by doc_count (unless showOutOfStockOption or keepValuesStatic) - Creates missing labels from keys - Hides single-value options if hideSingleOption enabled - Removes empty options from DOM - Applies sortType (key-asc, key-desc, etc.) - Formats rating labels with star text - Sets multiple select type for certain filter types
Example
Override to add custom option processing:
updateValuesOptions(options, settingOptionValues) {
const updated = super.updateValuesOptions(options, settingOptionValues);
// Add custom processing for shop-specific filters
return updated.map(option => {
if (option.filterType === 'vendor') {
// Add vendor logos to values
option.values = option.values.map(v => ({
...v,
logo: this.getVendorLogo(v.key)
}));
}
return option;
});
}