I want to make a simple view that counts all the offers of a product.
I use Drupal 7.9 and latest dev version of Views. Please help.

$view = new view;
$view->name = 'test_offers';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'test_offers';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'test_offers';
$handler->display->display_options['group_by'] = TRUE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['group_rendered'] = 1;
$handler->display->display_options['style_options']['columns'] = array(
'field_product' => 'field_product',
'title' => 'title',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'field_product' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'title' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
/* Field: Content: Product */
$handler->display->display_options['fields']['field_product']['id'] = 'field_product';
$handler->display->display_options['fields']['field_product']['table'] = 'field_data_field_product';
$handler->display->display_options['fields']['field_product']['field'] = 'field_product';
$handler->display->display_options['fields']['field_product']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_product']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_product']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_product']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_product']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_product']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_product']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_product']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_product']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_product']['click_sort_column'] = array(
0 => 'nid',
);
$handler->display->display_options['fields']['field_product']['field_api_classes'] = 0;
/* Field: COUNT(Content: Title) */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['group_type'] = 'count';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = 1;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'offer' => 'offer',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'test-offers';
$translatables['test_offers'] = array(
t('Master'),
t('test_offers'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Items per page'),
t('- All -'),
t('Offset'),
t('Product'),
t('Title'),
t('Page'),
);

Comments

dawehner’s picture

Can you please be more specific with your question? What do you mean with "can't use"? You don't know how to use it?

icanko’s picture

Sorry, it is a problem I have been postponing for a while now and when I started it couldn't actually fix it after many tries. I was really frustrated when writing that.

What I am trying to do is to have a view where several nodes get grouped by their common field (a node-reference) and have another field count the instances of repetition. I am planning adding other fields with average values once I master this.
So I have 10 nodes some of which have the same node referred in the node-reference field. Yet when I turn on "use aggregation" nothing happens.

icanko’s picture

Status: Active » Closed (fixed)

OK. I finally got it to work.
I removed all the fields, sorts and filters in the view then started adding 1 at a time and it works now.
No idea what was wrong in my previous tries.