Build UI
Modify Request
Overview
7min
modify request to modify a search request, the outgoing query to the indexed catalog is intercepted and any of the available klevu api parameters are available to be inserted, or adjusted as needed there are two steps reference the api to understand what parameters are available to meet the objective attach the override to the appropriate outgoing query (or queries) api referencing any of the klevu api parameters are available to be applied as needed or otherwise to override any default values for example, the following snippet of an outgoing productlist api request assigns the value of "10" as the number of filter options to return recordqueries \[ { filters { filterstoreturn { options { limit 10 } } }, id "productlist", typeofrequest "search", settings { query { term "jackets" } } } ], see klevu api documentation on retrieving filters for more details and options attaching the override the query parameters are directly added or replaced by using the klevu modifyrequest function klevu modifyrequest ("\<scope>", "\<parameter object>", "\<parameter value>"); the parameter object notation corresponds to that used in the outgoing json api query for example, the following example snippet modifies the outgoing productlist api query by assigning the value of "20" as the number of filter options to return klevu modifyrequest("landing", " productlist filters filterstoreturn options limit ", 20 ); the following full object notation syntax is also acceptable klevu modifyrequest("landing","productlist", { filters { filterstoreturn { options { limit 20 } } } }); advanced data objects or modules can be accessed using a callback function as the parameter object klevu modifyrequest("landing", function(data, scope){ console log('modifyrequest data',data); }); determining scope note that each klevu modifyrequest function requires definition within the corresponding scope of the override we will chart these below scope description all applies to all scope modules quick quicksearch module landing srlp module catnav category module full page both srlp and category modules (same as "landing,catnav") multiple klevu modifyrequest functions can be applied in the same or mixed scope examples please see the modify request examples docid\ hs9u2 i3txfu0fhsg atk section for details of common uses