Skip to main content
2 of 3
edited tags

hook_views_query_alter all condition

I have an exposed filter that shows products which have multiple entity references. The user should be able to pick some number of entities and the view should show entities containing all those references. In my mind that should mean changing the in operator on the where clause to an all operator.

function hook_views_query_alter(&$view, &$query) {
  if ($view->vid == 7) {
    dpm ($query);
    if (isset($query->where[1]['conditions'][2]['operator'])) {
      $query->where[1]['conditions'][2]['operator'] = 'all';
    }
    dpm ($query);
  }
}

However this seems to have no effect. the operator is changed from the first dpm to the second and it does break if I enter some other value in the all does not change the results. Do I have the wrong operator? Or am I going about this all wrong?