diff --git a/app/Importer/LocationImporter.php b/app/Importer/LocationImporter.php index 70058347676..5a87d069e50 100644 --- a/app/Importer/LocationImporter.php +++ b/app/Importer/LocationImporter.php @@ -39,14 +39,15 @@ public function createLocationIfNotExists(array $row) $editingLocation = false; + $location = Location::where('name', '=', $this->findCsvMatch($row, 'name'))->first(); + if ($this->findCsvMatch($row, 'id')!='') { + // Override location if an ID was given + \Log::debug('Finding location by ID: '.$this->findCsvMatch($row, 'id')); $location = Location::find($this->findCsvMatch($row, 'id')); - } else { - $location = Location::where('name', '=', $this->findCsvMatch($row, 'name'))->first(); } - if ($location) { if (! $this->updating) { $this->log('A matching Location '.$this->item['name'].' already exists');