🇲🇽Mexico @preciado04

Tepic
Account created on 18 December 2019, about 5 years ago
  • Semi Senior Drupal Developer at Globant 
  • Senior Drupal Developer at D4ALL 
#

Recent comments

🇲🇽Mexico preciado04 Tepic

Comment #13 🐛 Duplicate nodes when using Views relationships Closed: duplicate worked for me.

The only detail is, I had to modify a little bit the query.

use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\query\QueryPluginBase;

/**
 * Implements hook_views_query_alter().
 */
function mymodule_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
  switch($view->storage->id()){
    case 'my_view_id';
      $query->addField('node', 'nid', '', ['function' => 'groupby']);
      $query->addGroupBy('node.nid');
      break;
  }
}
Production build 0.71.5 2024