fix: make bpn import resilient to missing data
This commit is contained in:
@@ -83,7 +83,11 @@ class BpnImportCommand extends Command
|
||||
foreach ($destinationXml->xpath('zustiege/zustieg') as $pickupXml) {
|
||||
$pickupBusProId = (int) $pickupXml->attributes()['idbuspro'];
|
||||
if ($pickupBusProId) {
|
||||
$pickup = $this->pickupDataProvider->get($pickupBusProId);
|
||||
if (null === $pickup = $this->pickupDataProvider->get($pickupBusProId)) {
|
||||
$io->warning('Pickup with busProId '.$pickupBusProId.' not found');
|
||||
continue;
|
||||
}
|
||||
|
||||
$datePickups[] = [
|
||||
'busProId' => $pickupBusProId,
|
||||
'city' => $pickup->getCity(),
|
||||
@@ -96,7 +100,10 @@ class BpnImportCommand extends Command
|
||||
// Iterate over all hotel entries
|
||||
foreach ($destinationXml->xpath('hotel') as $hotelXml) {
|
||||
$hotelBusProId = (int) $hotelXml->attributes()['idbuspro'];
|
||||
$hotel = $this->hotelDataProvider->get($hotelBusProId);
|
||||
if (null === $hotel = $this->hotelDataProvider->get($hotelBusProId)) {
|
||||
$io->warning('Hotel with busProId '.$hotelBusProId.' not found');
|
||||
continue;
|
||||
}
|
||||
|
||||
// Finally update or store collected data
|
||||
if ($id = $this->connection->fetchOne('SELECT id FROM destination WHERE bus_pro_id=? AND hotel_bus_pro_id=?', [$busProId, $hotelBusProId])) {
|
||||
|
||||
Reference in New Issue
Block a user