How to get a view result programmatically without exposed filters respected I have some views of display page which I do not want to show to public if there would not be any result when accessed without any exposed filters set. I have a custom views access plugin and a custom access checking class which can handle the access granting.
My idea so far is that I would like to run the view a first time during access checking without exposed filters. In this way I could find out if the view would ever deliver any results. I tried it in the following way:
  $view = Views::getView($view_id);
  $view-&gt;setDisplay($display_id);
  $view-&gt;setArguments([$politician_id]);
  $view-&gt;execute();
  $result = $view-&gt;total_rows;

The problem is: as soon as an user comes to this page with query parameters in the url set by exposed filters these exposed filters are used for this view query as well. I did not find any way to tell the class in $view to execute without exposed filters. I even tried to set these exposed filters data in the following ways but even then the filter data in the query parameters is still used to filter the result set:
  $view = Views::getView($view_id);
  $view-&gt;setDisplay($display_id);
  $view-&gt;setArguments([$politician_id]);
  $view-&gt;initDisplay();
  $view-&gt;initHandlers();
  $view-&gt;setExposedInput([]);
  $view-&gt;exposed_data = [];
  $view-&gt;exposed_raw_input = [];
  $view-&gt;execute();
  $result = $view-&gt;total_rows;

I want to achieve that in this way because I want to use this logic for several views. It would be so smart to simply re-use the arguments and filters set in the views instead of hardcoding a new custom database query as the settings in the views might change. I hope someone can help me.
Thanks to 4k4 (see comments). The solution is to set some dummy exposed filter data:
  $view = Views::getView($view_id);
  $view-&gt;setDisplay($display_id);
  $view-&gt;setArguments([$politician_id]);
  $view-&gt;setExposedInput([
    'dummy' =&gt; ''
  ]);
  $view-&gt;execute();
  $result = $view-&gt;total_rows;

In this way it works.