Home > widget-integration > FilterService > fillFilterTree

FilterService.fillFilterTree() method

Enriches filter tree with complete option data and metadata.

Takes available filter options and selected filters, updates option values based on settings, and fills missing metadata for selected filters. Returns a complete filter tree with display labels, dependencies, and type information.

Signature:

fillFilterTree(filterOptions: any[], selectedFilters: any[], settingOptionValues: {
		showOutOfStockOption?: boolean;
		hideSingleOption?: boolean;
	}): any[];

Parameters

Parameter

Type

Description

filterOptions

any[]

Available filter options from API

selectedFilters

any[]

Currently selected filters (may have incomplete data)

settingOptionValues

{ showOutOfStockOption?: boolean; hideSingleOption?: boolean; }

Settings controlling option display

Returns:

any[]

Enriched selected filters with full metadata for rendering

Remarks

This method coordinates updateValuesOptions() and fillMissValueForFilterTree() to create a complete filter tree ready for rendering.

Example

Override to customize filter tree processing:

fillFilterTree(filterOptions, selectedFilters, settingOptionValues) {
  const enriched = super.fillFilterTree(filterOptions, selectedFilters, settingOptionValues);
  // Add custom shop-specific filter metadata
  return enriched.map(filter => ({
    ...filter,
    customMetadata: this.getCustomFilterMetadata(filter.data.key)
  }));
}