Skip to content

ProductsSearchUrl

The ProductsSearchUrl object extends the Url object. Represents a link to the search results - a list of products that meet the conditions specified in the query.

classDiagram
  direction LR
  ProductsSearchUrl <|-- Url
  class Url{
  }
  class ProductsSearchUrl{
    array params
    ProductsSearchUrl forPage(int page)
    ProductsSearchUrl forView(string view)
    ProductsSearchUrl forSort(int sort)
  }

Methods

url.forPage(int page)

Method returns ProductsSearchUrl object with the page parameter set in the url.

source
{{ url.forPage(4).relative }}
output
/pl/searchquery/conditions-query/4

url.forView(string view)

Method returns ProductsSearchUrl object with the view parameter set in the url.

source
{{ url.forView(view-name) }}
output
/pl/searchquery/conditions-query/1/test-view

url.forSort(int sort)

Method returns ProductsSearchUrl object with the sort parameter set in the url

source
{{ url.forSort(5).relative }}
output
/pl/searchquery/conditions-query/1/default/5

Examples

Displaying absolute url with page parameter set:

source
{{ url.forPage(3).absolute }}
output
https://domain.com//pl/searchquery/conditions-query/3

Displaying absolute url with view parameter set:

source
{{ url.forView(view-example).absolute }}
output
https://domain.com/pl/searchquery/conditions-query/1/view-example

It is also possible to call these methods in chain and build an url with multiple parameters:

source
{{ url.forPage(2).forView(example-view).forSort(10).absolute }}
output
https://domain.com//pl/searchquery/conditions-query/1/example-view/10