asipple1
3/19/2019 - 3:16 PM

Drupal 8 Views results count.

use Drupal\views\Views;

parse_str($_SERVER['QUERY_STRING'], $url_query_array);
$results_view = Views::getView('view_display_name');
$results_view->setDisplay('view_machine_name');
$results_view->setArguments($url_query_array);
$results_view->preExecute();
$results_view->execute();
$view_results_count = $results_view->total_rows;