Hi, i am a newbie of everything, so your help is appreciated a lot. I have gone through all the tutorials and screencasts I found, but this seems a little advanced.

I am trying to build a bookstore. I am simply trying to make a block view that displays 'other books of this author'.

I have a book product entity. Authors are taxonomy terms and product entities are tagged with them. I have a book product display node. The view is gonna be a block on this node.

The referencing flow should simply be:
Current node -> Referenced product entity from current node -> Tagged product entities with the same term -> Product display nodes referencing these entities

So I need to create a contextual filter (which is not very easy on the block view) that takes the product via relationship but then finds its author.

Any help is appreciated a lot. Thanks in advance.

Comments

rszrama’s picture

Status: Active » Fixed

I don't remember the precise configuration, but it's not that difficult to get a block pulling the nid from the URL since you know that every node uses the URL structure of node/%nid. Once you have the node, then you'd add a relationship to the referenced product, and from there you'd be able to use its term as a filter. (You might need to add another relationship to the referenced terms... can't remember how that integration works.) Once you've filtered your products View to those referenced products, you're going to want to add a reverse product reference relationship (i.e. Nodes referencing this product) so you can get the title / link for the actual View results.

I don't have time to go through this, but perhaps you can take this description to #drupal-views or #drupal-commerce and have someone walk you through parts you don't understand (or I got wrong ; ). If you solve it, we'd love to see the results here.

durum’s picture

Thanks for the time, Ryan.
I was sure I tried this before, but this time it happened to be successful.

I am getting the node id as contextual filter.
I have these relationships:
- referenced product entity (as product entity)
- (product entity) Commerce Product: Author (field_author)
- (term from field_author) Taxonomy term: Commerce Product using Author
- (field_author) Commerce Product: Node referencing products from field_book

Export of view looks like this:

$view = new view;
$view->name = 'other_books_of_this_author';
$view->description = '';
$view->tag = 'taxonomy';
$view->base_table = 'node';
$view->human_name = 'Other books of this author';
$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'] = 'Other books of this author';
$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']['disable_sql_rewrite'] = TRUE;
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['style_plugin'] = 'fluid_grid';
$handler->display->display_options['style_options']['items_width'] = '200';
$handler->display->display_options['style_options']['box_shadow'] = '0';
$handler->display->display_options['style_options']['border_radius'] = '0';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: product entity */
$handler->display->display_options['relationships']['field_book_product_id']['id'] = 'field_book_product_id';
$handler->display->display_options['relationships']['field_book_product_id']['table'] = 'field_data_field_book';
$handler->display->display_options['relationships']['field_book_product_id']['field'] = 'field_book_product_id';
$handler->display->display_options['relationships']['field_book_product_id']['ui_name'] = 'product entity';
$handler->display->display_options['relationships']['field_book_product_id']['label'] = 'product entity';
$handler->display->display_options['relationships']['field_book_product_id']['required'] = 1;
/* Relationship: Commerce Product: Author (field_author) */
$handler->display->display_options['relationships']['field_author_tid']['id'] = 'field_author_tid';
$handler->display->display_options['relationships']['field_author_tid']['table'] = 'field_data_field_author';
$handler->display->display_options['relationships']['field_author_tid']['field'] = 'field_author_tid';
$handler->display->display_options['relationships']['field_author_tid']['relationship'] = 'field_book_product_id';
$handler->display->display_options['relationships']['field_author_tid']['required'] = 1;
/* Relationship: Taxonomy term: Commerce Product using Author */
$handler->display->display_options['relationships']['reverse_field_author_commerce_product']['id'] = 'reverse_field_author_commerce_product';
$handler->display->display_options['relationships']['reverse_field_author_commerce_product']['table'] = 'taxonomy_term_data';
$handler->display->display_options['relationships']['reverse_field_author_commerce_product']['field'] = 'reverse_field_author_commerce_product';
$handler->display->display_options['relationships']['reverse_field_author_commerce_product']['relationship'] = 'field_author_tid';
$handler->display->display_options['relationships']['reverse_field_author_commerce_product']['required'] = 1;
/* Relationship: Commerce Product: Node referencing products from field_book */
$handler->display->display_options['relationships']['field_book']['id'] = 'field_book';
$handler->display->display_options['relationships']['field_book']['table'] = 'commerce_product';
$handler->display->display_options['relationships']['field_book']['field'] = 'field_book';
$handler->display->display_options['relationships']['field_book']['relationship'] = 'reverse_field_author_commerce_product';
$handler->display->display_options['relationships']['field_book']['label'] = 'Node referencing products from field_book';
$handler->display->display_options['relationships']['field_book']['required'] = 1;
/* Field: Content: Path */
$handler->display->display_options['fields']['path']['id'] = 'path';
$handler->display->display_options['fields']['path']['table'] = 'node';
$handler->display->display_options['fields']['path']['field'] = 'path';
$handler->display->display_options['fields']['path']['label'] = '';
$handler->display->display_options['fields']['path']['exclude'] = TRUE;
$handler->display->display_options['fields']['path']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['path']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['path']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['path']['alter']['external'] = 0;
$handler->display->display_options['fields']['path']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['path']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['path']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['path']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['path']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['path']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['path']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['path']['alter']['trim'] = 0;
$handler->display->display_options['fields']['path']['alter']['html'] = 0;
$handler->display->display_options['fields']['path']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['path']['element_default_classes'] = 1;
$handler->display->display_options['fields']['path']['hide_empty'] = 0;
$handler->display->display_options['fields']['path']['empty_zero'] = 0;
$handler->display->display_options['fields']['path']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['path']['absolute'] = 0;
/* Field: Commerce Product: Cover */
$handler->display->display_options['fields']['field_cover']['id'] = 'field_cover';
$handler->display->display_options['fields']['field_cover']['table'] = 'field_data_field_cover';
$handler->display->display_options['fields']['field_cover']['field'] = 'field_cover';
$handler->display->display_options['fields']['field_cover']['relationship'] = 'reverse_field_author_commerce_product';
$handler->display->display_options['fields']['field_cover']['label'] = '';
$handler->display->display_options['fields']['field_cover']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_cover']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_cover']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_cover']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_cover']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_cover']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_cover']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_cover']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_cover']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_cover']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_cover']['settings'] = array(
  'image_style' => 'thumbnail',
  'image_link' => '',
);
$handler->display->display_options['fields']['field_cover']['field_api_classes'] = 0;
/* Field: 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']['relationship'] = 'field_book';
$handler->display->display_options['fields']['title']['label'] = '';
$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'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['more_link'] = 0;
$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'] = FALSE;
$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;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Commerce Product: Publisher */
$handler->display->display_options['fields']['field_publisher']['id'] = 'field_publisher';
$handler->display->display_options['fields']['field_publisher']['table'] = 'field_data_field_publisher';
$handler->display->display_options['fields']['field_publisher']['field'] = 'field_publisher';
$handler->display->display_options['fields']['field_publisher']['relationship'] = 'field_book_product_id';
$handler->display->display_options['fields']['field_publisher']['label'] = '';
$handler->display->display_options['fields']['field_publisher']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_publisher']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_publisher']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_publisher']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_publisher']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_publisher']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_publisher']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_publisher']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_publisher']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_publisher']['field_api_classes'] = 0;
/* 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';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['exception']['title'] = 'All';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['nid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['nid']['specify_validation'] = 1;
$handler->display->display_options['arguments']['nid']['validate']['type'] = 'node';
$handler->display->display_options['arguments']['nid']['validate_options']['types'] = array(
  'bookpage' => 'bookpage',
);
$handler->display->display_options['arguments']['nid']['validate_options']['access'] = 0;
$handler->display->display_options['arguments']['nid']['validate']['fail'] = 'empty';
$handler->display->display_options['arguments']['nid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['nid']['not'] = 0;
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid_1']['id'] = 'nid_1';
$handler->display->display_options['arguments']['nid_1']['table'] = 'node';
$handler->display->display_options['arguments']['nid_1']['field'] = 'nid';
$handler->display->display_options['arguments']['nid_1']['relationship'] = 'field_book';
$handler->display->display_options['arguments']['nid_1']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid_1']['exception']['title'] = 'All';
$handler->display->display_options['arguments']['nid_1']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['nid_1']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['nid_1']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid_1']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid_1']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['nid_1']['break_phrase'] = 0;
$handler->display->display_options['arguments']['nid_1']['not'] = 1;
/* 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'] = 1;
$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']['relationship'] = 'field_book';
$handler->display->display_options['filters']['type']['value'] = array(
  'bookpage' => 'bookpage',
);

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
$translatables['other_books_of_this_author'] = array(
  t('Master'),
  t('Other books of this author'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('product entity'),
  t('term from field_author'),
  t('field_author'),
  t('Node referencing products from field_book'),
  t('All'),
  t('Block'),
);
rszrama’s picture

Great, thanks for sharing! : )

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.