You are here

protected function FeedsUcAddressesProcessor::existingEntityId in Ubercart Addresses 7

Get address ID of an existing feed item address if available.

File

feeds/FeedsUcAddressesProcessor.inc, line 201
Contains the FeedsUcAddressesProcessor class.

Class

FeedsUcAddressesProcessor
A processor for importing data belonging to an Ubercart Addresses address.

Code

protected function existingEntityId(FeedsSource $source, FeedsParserResult $result) {
  $aid = parent::existingEntityId($source, $result);
  if ($aid) {
    return $aid;
  }

  // Iterate through all unique targets and test whether they do already
  // exist in the database.
  foreach ($this
    ->uniqueTargets($source, $result) as $target => $value) {
    switch ($target) {
      case 'aid':
        $aid = db_select('uc_addresses')
          ->fields('uc_addresses', array(
          'aid',
        ))
          ->condition('aid', $value)
          ->execute()
          ->fetchField();
        break;
    }
    if ($aid) {

      // Return with the first address ID found.
      return $aid;
    }
  }
  return 0;
}