Home > widget-integration > FilterUrlHelper > rewriteUrlFromParams

FilterUrlHelper.rewriteUrlFromParams() method

Rewrites the URL with new filter parameters, sort, and pagination.

Clears all existing filter parameters and sets new ones based on provided data. This is a complete URL reconstruction, useful for applying bulk filter changes.

Signature:

rewriteUrlFromParams(data: {
		paramList: Array<{
			key: string;
			values: string[];
		}>;
		sort: string | null;
		pagination: {
			page: string | null;
		};
	}, options?: {
		isShortenUrlParam?: boolean;
		urlScheme?: number;
	}): void;

Parameters

Parameter

Type

Description

data

{ paramList: Array<{ key: string; values: string[]; }>; sort: string | null; pagination: { page: string | null; }; }

Object containing complete filter state

options

{ isShortenUrlParam?: boolean; urlScheme?: number; }

(Optional) Configuration options for URL handling

Returns:

void

Remarks

This method performs a complete URL rewrite in several steps: 1. Preserves 'q' (search query) and 'collection_scope' parameters 2. Removes all existing filter parameters (identified by FILTER_KEY_PREFIX) 3. Clears standard parameters (sort, page) 4. Applies new parameters from the data object 5. Uses replaceState to avoid creating new history entry

Performance note: For large filter sets, this is more efficient than multiple individual parameter operations.

Example

Rewrite URL with new filter state:

this.urlHelper.rewriteUrlFromParams({
  paramList: [
    { key: 'pf_brand', values: ['Nike'] },
    { key: 'pf_color', values: ['Red', 'Blue'] }
  ],
  sort: 'price-asc',
  pagination: { page: '1' }
});