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) {
|
foreach ($destinationXml->xpath('zustiege/zustieg') as $pickupXml) {
|
||||||
$pickupBusProId = (int) $pickupXml->attributes()['idbuspro'];
|
$pickupBusProId = (int) $pickupXml->attributes()['idbuspro'];
|
||||||
if ($pickupBusProId) {
|
if ($pickupBusProId) {
|
||||||
$pickup = $this->pickupDataProvider->get($pickupBusProId);
|
if (null === $pickup = $this->pickupDataProvider->get($pickupBusProId)) {
|
||||||
|
$io->warning('Pickup with busProId '.$pickupBusProId.' not found');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$datePickups[] = [
|
$datePickups[] = [
|
||||||
'busProId' => $pickupBusProId,
|
'busProId' => $pickupBusProId,
|
||||||
'city' => $pickup->getCity(),
|
'city' => $pickup->getCity(),
|
||||||
@@ -96,7 +100,10 @@ class BpnImportCommand extends Command
|
|||||||
// Iterate over all hotel entries
|
// Iterate over all hotel entries
|
||||||
foreach ($destinationXml->xpath('hotel') as $hotelXml) {
|
foreach ($destinationXml->xpath('hotel') as $hotelXml) {
|
||||||
$hotelBusProId = (int) $hotelXml->attributes()['idbuspro'];
|
$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
|
// 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])) {
|
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