You are here

function apachesolr_field_collection_indexing_callback in Apache Solr Field Collection 7

Indexing callback for field collection fields.

1 string reference to 'apachesolr_field_collection_indexing_callback'
apachesolr_field_collection_apachesolr_field_mappings in ./apachesolr_field_collection.module
Implements hook_apachesolr_field_mappings().

File

./apachesolr_field_collection.module, line 30
Allows field collections to be indexed and faceted via the entity they are attached to.

Code

function apachesolr_field_collection_indexing_callback($entity, $field_name, $index_key, $field_info) {

  // Load each field collection item and add its fields to the index.
  $fields = array();
  if (!empty($entity->{$field_name})) {
    foreach ($entity->{$field_name} as $field_collections) {
      foreach ($field_collections as $field_collection) {
        if (($item_id = $field_collection['value']) && ($field_collection_item = field_collection_item_load($item_id))) {
          apachesolr_field_collection_add_field_collection_fields($fields, $field_collection_item);
        }
      }
    }
  }
  return $fields;
}