You are here

function search_api_grouping_generate_permuatations in Search API Grouping 7.2

Execution callback for the cron queue item.

1 call to search_api_grouping_generate_permuatations()
drush_search_api_grouping_process_permutation_queue in ./search_api_grouping.drush.inc
Processes queue items.
4 string references to 'search_api_grouping_generate_permuatations'
drush_search_api_grouping_process_permutation_queue in ./search_api_grouping.drush.inc
Processes queue items.
SearchApiDenormalizedEntityDataSourceController::queuePermutationGeneration in includes/datasource_denormalized_entity.inc
Queues the generation of the permutations.
SearchApiDenormalizedEntityDataSourceController::startTracking in includes/datasource_denormalized_entity.inc
Initialize tracking of the index status of items for the given indexes.
search_api_grouping_cron_queue_info in ./search_api_grouping.module
Implements hook_cron_queue_info().

File

./search_api_grouping.module, line 367
Module search_api_grouping.

Code

function search_api_grouping_generate_permuatations($queue_item) {

  // Bundle the items by entity type. That way we can send bundles of items to
  // method and reduce the amount of db writes.
  $entity_type_items = array();
  foreach ($queue_item as $item) {
    $entity_type_items[$item->entity_type][$item->etid] = $item;
  }
  $indexes = search_api_index_load_multiple(FALSE);

  // Now iterate over all entity type bundles.
  foreach ($entity_type_items as $entity_type => $items) {

    // Prepare the entities to process.
    $entities = entity_load($entity_type, array_keys($items));

    // Iterate over all indexes and generate the item permutations for
    // denormalized indexes.
    foreach ($indexes as $index) {
      if ($index
        ->datasource() instanceof SearchApiDenormalizedEntityDataSourceController) {
        $index
          ->datasource()
          ->createPermutationItems($index, $entity_type, $entities);
      }
    }
  }
}