#1791 removed terms thesaurus without parents from search form autocomplete
This commit is contained in:
		@@ -73,6 +73,14 @@ field_settings:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      module:
 | 
			
		||||
        - taxonomy
 | 
			
		||||
  parent:
 | 
			
		||||
    label: 'Parents du terme'
 | 
			
		||||
    datasource_id: 'entity:taxonomy_term'
 | 
			
		||||
    property_path: parent
 | 
			
		||||
    type: integer
 | 
			
		||||
    dependencies:
 | 
			
		||||
      module:
 | 
			
		||||
        - taxonomy
 | 
			
		||||
  status:
 | 
			
		||||
    label: Published
 | 
			
		||||
    datasource_id: 'entity:taxonomy_term'
 | 
			
		||||
@@ -97,6 +105,14 @@ field_settings:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      module:
 | 
			
		||||
        - taxonomy
 | 
			
		||||
  vid:
 | 
			
		||||
    label: Vocabulaire
 | 
			
		||||
    datasource_id: 'entity:taxonomy_term'
 | 
			
		||||
    property_path: vid
 | 
			
		||||
    type: string
 | 
			
		||||
    dependencies:
 | 
			
		||||
      module:
 | 
			
		||||
        - taxonomy
 | 
			
		||||
datasource_settings:
 | 
			
		||||
  'entity:taxonomy_term':
 | 
			
		||||
    bundles:
 | 
			
		||||
@@ -113,6 +129,7 @@ processor_settings:
 | 
			
		||||
  add_url: {  }
 | 
			
		||||
  aggregated_field: {  }
 | 
			
		||||
  entity_status: {  }
 | 
			
		||||
  entity_type: {  }
 | 
			
		||||
  language_with_fallback: {  }
 | 
			
		||||
  rendered_item: {  }
 | 
			
		||||
  solr_date_range:
 | 
			
		||||
 
 | 
			
		||||
@@ -54,6 +54,21 @@ class FormAutocomplete extends ControllerBase {
 | 
			
		||||
      // Add sorting.
 | 
			
		||||
      $query->sort('search_api_relevance', 'DESC');
 | 
			
		||||
 | 
			
		||||
      // remove thesaurus tags without parents (main categories)
 | 
			
		||||
      $parents_conditions = $query->createConditionGroup('OR');
 | 
			
		||||
      // tags
 | 
			
		||||
      $tags_conditions = $query->createConditionGroup('AND');
 | 
			
		||||
      $tags_conditions->addCondition('vid', 'tags');
 | 
			
		||||
      $parents_conditions->addConditionGroup($tags_conditions);      
 | 
			
		||||
      // OR thesaurus & has parent
 | 
			
		||||
      $thesaurus_conditions = $query->createConditionGroup('AND');
 | 
			
		||||
      $thesaurus_conditions->addCondition('vid', 'thesaurus');
 | 
			
		||||
      $thesaurus_conditions->addCondition('parent', 0, '<>');
 | 
			
		||||
      $parents_conditions->addConditionGroup($thesaurus_conditions);      
 | 
			
		||||
      
 | 
			
		||||
      $query->addConditionGroup($parents_conditions);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      // Set one or more tags for the query.
 | 
			
		||||
      // @see hook_search_api_query_TAG_alter()
 | 
			
		||||
      // @see hook_search_api_results_TAG_alter()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user