Limit search with aldryn_search to results from current site_id only

Hello,

is it possible to limit the search results to the current site only? I have two sites having SITE_ID=1 and SITE_ID=2 respectfully, and I use django-cms==3.8 for creating static pages. Each of the pages belongs to one site only, but in the search results all pages are listed intermittently belonging to all the sites. I can hide the extra items in the results comparing the site_id value, but it will lead to a messed-up pagination.

Are there any ways of figuring it out? Thanks!
Alex

I found the answer myself. You subclass a new class from the AldrynSearchView as follows:

search/views.py:

from django.contrib.sites.models import Site

class SearchView(AldrynSearchView):

    def get(self, request, *args, **kwargs):
        return super(SearchView, self).get(request, *args, **kwargs)

    def get_queryset(self):
        sqs = super(SearchView, self).get_queryset()

        site = Site.objects.get_current()

        sqs = sqs.filter(site_id = site.pk)
        return sqs

Don’t forget to register the new search app via apphook_pool.register. That solves it.
Hope this solution will be helpful to someone.