Skip to content

Commit

Permalink
feat ⭐ utilize items_per_page to paginate results
Browse files Browse the repository at this point in the history
  • Loading branch information
samar-hassan committed Nov 13, 2024
1 parent 90ed9a4 commit b46dbf3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions oscar_elasticsearch/search/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def get_context_data(self, *args, **kwargs):
self.form = self.get_form(self.request)
self.form.is_valid()

self.paginate_by = self.form.cleaned_data.get(
"items_per_page", settings.DEFAULT_ITEMS_PER_PAGE
)
elasticsearch_from = (
int(self.request.GET.get("page", 1)) * self.paginate_by
) - self.paginate_by
Expand All @@ -129,6 +132,7 @@ def get_context_data(self, *args, **kwargs):
paginator, search_results, unfiltered_result = (
product_search_api.paginated_facet_search(
from_=elasticsearch_from,
to=self.paginate_by,
query_string=query_string,
filters=self.get_default_filters(),
sort_by=self.get_sort_by(),
Expand Down

0 comments on commit b46dbf3

Please sign in to comment.