ws-page-size-selector component lets you control how many hits are loaded on the search result page or the category page. Depending on the mode, the customer can choose the number of hits per page themselves, load more hits via a button, or have the next hits displayed automatically while scrolling.
Three modes are available:
select: Selection of the number of hits per page via a dropdown list. This is the default presentation.button: A button loads the next hits and appends them to the result list.infinite: New hits are loaded automatically as soon as the customer reaches the end of the result list (infinite scrolling).
button and infinite, the component replaces the classic page navigation. A ws-pagination is then not required.
Component
The component can be embedded as follows on the category and search result page: Select mode- Attributes:
class: Lets you assign a class to the element itself.mode: Specifies how the presentation should be rendered.select: Rendered as a dropdown list.select-class: Class for the generated select element.options: List of available options for the number of hits per page, for example[16, 32, 48, 64, 80]. The value0creates the “Show all” option, see Show all hits.page-size-all: Optional. Maximum number of hits loaded via the “Show all” option. Default:10000page-size-all-label: Optional. Label of the “Show all” option. Default:All
button: A “Show more” button without paging.label: Text displayed on the button.btn-class: Class for the button.
infinite: Automatic loading while scrolling, see Infinite scrolling.scroll-offset: Distance in pixels before the end of<ws-search-result>at which loading starts. Default:300
Show all hits
In addition to fixed numbers of hits, the selection can contain an option that displays all hits on one page. To do this, add the value0 to the options attribute. The component does not display this value as a number, however, but as the “Show all” option.
page-size-alldefines the maximum number of hits loaded with “Show all”. If not specified, the value10000applies.page-size-all-labeldefines the label of the option. If not specified, it isAll. For German-language shops, this attribute should therefore be set.
The number of hits is technically limited to 10,000. This limit is imposed by Elasticsearch. Even a higher value in
page-size-all therefore loads at most 10,000 hits.page-size-all, such as 500, keeps the page responsive.
Infinite scrolling
With theinfinite mode, the component loads new hits without the customer having to click. For this, the <ws-page-size-selector> works as a so-called sentinel. This is an invisible element with a height of one pixel. As soon as it enters the visible area while scrolling, the component loads the next hits and appends them to the result list.
For this to work, the component must be placed directly below <ws-search-result>. Only then is the sentinel located at the end of the result list and triggers loading at the right moment.
page-size of <ws-search>, just as in button mode. Loading starts as soon as the customer is 300 pixels before the end of the result list. This way, the next hits are usually already available before the customer reaches the end. With a larger scroll-offset, loading starts earlier.
