function _sf_import_process_records in Salesforce Suite 7.2
Same name and namespace in other branches
- 6.2 sf_import/sf_import.module \_sf_import_process_records()
Processes items in the sf_import_queue table.
3 calls to _sf_import_process_records()
- drush_sf_import_sf_get_updated in sf_import/
sf_import.drush.inc - Calls SF Import Get Updated
- sf_import_cron in sf_import/
sf_import.module - Implements hook_cron().
- sf_import_settings_form_submit in sf_import/
sf_import.admin.inc - Submit handler for the settings page.
File
- sf_import/
sf_import.module, line 200
Code
function _sf_import_process_records() {
// Process sf_import_queue items.
$fieldmaps = salesforce_api_salesforce_fieldmap_load_all();
$records = array();
$result = db_query("SELECT sfid, fieldmap FROM {sf_import_queue}");
foreach ($result as $sfids) {
$fieldmap = $sfids->fieldmap;
$type = $fieldmaps[$fieldmap]->drupal_entity;
// Check to see if the fieldmap matches a Drupal entity.
// If so, use the entity import function.
if ($entity_info = entity_get_info($type)) {
$type = 'entity';
}
$function = 'sf_' . $type . '_import';
$drupal_id = salesforce_api_get_id_with_sfid($sfids->sfid, $fieldmap);
if (function_exists($function)) {
// @todo: Ensure that this sets the proper linkage.
$oid = $function($sfids->sfid, $fieldmap, $drupal_id);
$records[] = array(
$sfids->sfid,
$oid,
$fieldmap,
);
}
db_delete('sf_import_queue')
->condition('sfid', $sfids->sfid)
->execute();
}
if (count($records) > 0) {
variable_set('sf_import_queue_processed_count', count($records));
return $records;
}
else {
variable_set('sf_import_queue_processed_count', 0);
return FALSE;
}
}