Commerce Kickstart: show child items when category is empty
Hi!
I have a unique product type in my commerce kickstart site but this type has a lot of sub-categories.
The main menu is generated by taxonomy terms and the "main" categories are empty.
For example:
- bicycles
--- Mountain Bikes
--- Trekking bikes
--- Runner bikes
The 3 sub-categories are full of products, the "bicycles" category is empty.
I'd like to display the content of the 3 sub-categories when I click the main category "bicycles", now it doesn't happen.
For now I display a message in case of empty results when I tell to go to all products but it's not really good for customers...
Here is my exported view:
$view = new view();
$view->name = 'collection_products';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'search_api_index_product_display';
$view->human_name = 'Collection products';
$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'] = '%1';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['use_more_text'] = 'altro';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Applica';
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Ripristina';
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Ordina per';
$handler->display->display_options['exposed_form']['options']['sort_desc_label'] = 'Disc';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'list';
$handler->display->display_options['style_options']['grouping'] = array(
0 => array(
'field' => 'name_1',
'rendered' => 1,
'rendered_strip' => 0,
),
);
$handler->display->display_options['style_options']['class'] = 'products-per-collection';
$handler->display->display_options['row_plugin'] = 'fields';
/* Intestazione: Globale: Area della vista */
$handler->display->display_options['header']['view']['id'] = 'view';
$handler->display->display_options['header']['view']['table'] = 'views';
$handler->display->display_options['header']['view']['field'] = 'view';
$handler->display->display_options['header']['view']['view_to_insert'] = 'collection_products:block_1';
$handler->display->display_options['header']['view']['inherit_arguments'] = TRUE;
/* Relazione: Category */
$handler->display->display_options['relationships']['field_product_category']['id'] = 'field_product_category';
$handler->display->display_options['relationships']['field_product_category']['table'] = 'search_api_index_product_display';
$handler->display->display_options['relationships']['field_product_category']['field'] = 'field_product_category';
$handler->display->display_options['relationships']['field_product_category']['ui_name'] = 'Category';
/* Relazione: Indexed Nodo: Prodotto */
$handler->display->display_options['relationships']['field_product']['id'] = 'field_product';
$handler->display->display_options['relationships']['field_product']['table'] = 'search_api_index_product_display';
$handler->display->display_options['relationships']['field_product']['field'] = 'field_product';
/* Campo: Termine della tassonomia: Nome */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'entity_taxonomy_term';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'field_category';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['exclude'] = TRUE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['link_to_entity'] = 0;
/* Campo: Contenuto: Rendered Nodo */
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_node';
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['label'] = '';
$handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
$handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
$handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'product_list';
/* Criterio di ordinamento: Indexed Nodo: Title */
$handler->display->display_options['sorts']['title_field']['id'] = 'title_field';
$handler->display->display_options['sorts']['title_field']['table'] = 'search_api_index_product_display';
$handler->display->display_options['sorts']['title_field']['field'] = 'title_field';
/* Filtro contestuale: Indexed Nodo: Categorie prodotti */
$handler->display->display_options['arguments']['field_product_category']['id'] = 'field_product_category';
$handler->display->display_options['arguments']['field_product_category']['table'] = 'search_api_index_product_display';
$handler->display->display_options['arguments']['field_product_category']['field'] = 'field_product_category';
$handler->display->display_options['arguments']['field_product_category']['default_action'] = 'not found';
$handler->display->display_options['arguments']['field_product_category']['exception']['title_enable'] = TRUE;
$handler->display->display_options['arguments']['field_product_category']['exception']['title'] = 'all';
$handler->display->display_options['arguments']['field_product_category']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['field_product_category']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['field_product_category']['summary_options']['grouping'] = array(
0 => array(
'field' => 'name_1',
'rendered' => 1,
'rendered_strip' => 0,
),
);
$handler->display->display_options['arguments']['field_product_category']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['field_product_category']['validate']['type'] = 'taxonomy_term';
$handler->display->display_options['arguments']['field_product_category']['validate_options']['vocabularies'] = array(
'product_category' => 'product_category',
);
$handler->display->display_options['arguments']['field_product_category']['break_phrase'] = 0;
$handler->display->display_options['arguments']['field_product_category']['not'] = 0;
/* Criterio del filtro: Indexed Nodo: Stato */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'search_api_index_product_display';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = array(
1 => '1',
);
/* Display: page */
$handler = $view->new_display('page', 'page', 'page');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = '%1';
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['empty'] = FALSE;
/* Comportamento se non ci sono risultati: Globale: Area di testo */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['label'] = 'Nessun risultato';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'La categoria scelta al momento non contiene prodotti, prova con le relative sotto-categorie o fai una ricerca tramite la pagina "Tutti i prodotti".';
$handler->display->display_options['empty']['area']['format'] = 'full_html';
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relazione: Category */
$handler->display->display_options['relationships']['field_product_category']['id'] = 'field_product_category';
$handler->display->display_options['relationships']['field_product_category']['table'] = 'search_api_index_product_display';
$handler->display->display_options['relationships']['field_product_category']['field'] = 'field_product_category';
$handler->display->display_options['relationships']['field_product_category']['ui_name'] = 'Category';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Campo: Termine della tassonomia: Nome */
$handler->display->display_options['fields']['name_1']['id'] = 'name_1';
$handler->display->display_options['fields']['name_1']['table'] = 'entity_taxonomy_term';
$handler->display->display_options['fields']['name_1']['field'] = 'name';
$handler->display->display_options['fields']['name_1']['relationship'] = 'field_product_category';
$handler->display->display_options['fields']['name_1']['label'] = '';
$handler->display->display_options['fields']['name_1']['exclude'] = TRUE;
$handler->display->display_options['fields']['name_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name_1']['link_to_entity'] = 0;
$handler->display->display_options['fields']['name_1']['replace_spaces'] = TRUE;
/* Campo: Termine della tassonomia: Nome */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'entity_taxonomy_term';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'field_product_category';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['exclude'] = TRUE;
$handler->display->display_options['fields']['name']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['name']['alter']['text'] = '[name]';
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['link_to_entity'] = 0;
$handler->display->display_options['fields']['name']['replace_spaces'] = TRUE;
/* Campo: Contenuto: Rendered Nodo */
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_node';
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['label'] = '';
$handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 0;
$handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
$handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'product_list';
$handler->display->display_options['path'] = 'product_category/%';
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['defaults']['css_class'] = FALSE;
$handler->display->display_options['css_class'] = 'collection-terms';
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'list';
$handler->display->display_options['style_options']['grouping'] = array(
0 => array(
'field' => 'name_1',
'rendered' => 0,
'rendered_strip' => 0,
),
);
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['header'] = FALSE;
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Campo: Termine della tassonomia: Nome */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'entity_taxonomy_term';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'field_category';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['exclude'] = TRUE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name']['link_to_entity'] = 0;
$handler->display->display_options['fields']['name']['replace_spaces'] = TRUE;
/* Campo: Termine della tassonomia: Nome */
$handler->display->display_options['fields']['name_1']['id'] = 'name_1';
$handler->display->display_options['fields']['name_1']['table'] = 'entity_taxonomy_term';
$handler->display->display_options['fields']['name_1']['field'] = 'name';
$handler->display->display_options['fields']['name_1']['relationship'] = 'field_category';
$handler->display->display_options['fields']['name_1']['label'] = '';
$handler->display->display_options['fields']['name_1']['exclude'] = TRUE;
$handler->display->display_options['fields']['name_1']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['name_1']['alter']['text'] = '[name_1]';
$handler->display->display_options['fields']['name_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name_1']['link_to_entity'] = 0;
/* Campo: Globale: Testo personalizzato */
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
$handler->display->display_options['fields']['nothing']['table'] = 'views';
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing']['label'] = '';
$handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['nothing']['hide_empty'] = TRUE;
$translatables['collection_products'] = array(
t('Master'),
t('%1'),
t('altro'),
t('Applica'),
t('Ripristina'),
t('Ordina per'),
t('Asc'),
t('Disc'),
t('Categorie prodotti'),
t('Prodotto'),
t('all'),
t('page'),
t('Nessun risultato'),
t('La categoria scelta al momento non contiene prodotti, prova con le relative sotto-categorie o fai una ricerca tramite la pagina "Tutti i prodotti".'),
t('[name]'),
t('Block'),
t('[name_1]'),
);
Comments
Me too!
I am also looking for the ability to do this. I imagine it has something to do with taxonomy and views.... but can anyone help?
-Michelle