Skip to content

Instantly share code, notes, and snippets.

@druman
Created April 1, 2017 12:35
Show Gist options
  • Save druman/e7cc0a2bb4a0e24c087f38ae411f90c9 to your computer and use it in GitHub Desktop.
Save druman/e7cc0a2bb4a0e24c087f38ae411f90c9 to your computer and use it in GitHub Desktop.
Duplicate comerce variations product in views. Need content:nid field!
/**
* Implements hook_views_pre_execute().
*
* Rewrite SQL query to prevent duplicates based on NID
*/
function my_module_views_pre_execute(&$view) {
if ($view->name == '') {
$query = $view->build_info['query'];
$count_query = $view->build_info['count_query'];
$query->groupBy('nid');
$count_query->groupBy('nid');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment