Adjust date import to changed xml structure
This commit is contained in:
@@ -262,8 +262,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
$this->logger->warning('product not found or daytrip', ['code' => $code]);
|
$this->logger->warning('product not found or daytrip', ['code' => $code]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
foreach ($products as $product)
|
foreach ($products as $product) {
|
||||||
{
|
|
||||||
$this->db->update(
|
$this->db->update(
|
||||||
'tx_epproducts_domain_model_product',
|
'tx_epproducts_domain_model_product',
|
||||||
['bus_pro_id' => $busProId],
|
['bus_pro_id' => $busProId],
|
||||||
@@ -289,8 +288,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
protected function parseDates(\SimpleXMLElement $xmlDate, array $product)
|
protected function parseDates(\SimpleXMLElement $xmlDate, array $product)
|
||||||
{
|
{
|
||||||
$dateCount = 0;
|
$dateCount = 0;
|
||||||
foreach ($xmlDate->hotel as $xmlHotel)
|
foreach ($xmlDate->hotel as $xmlHotel) {
|
||||||
{
|
|
||||||
$hotelCode = (string) $xmlHotel->attributes()['code'];
|
$hotelCode = (string) $xmlHotel->attributes()['code'];
|
||||||
$date = $this->createDateRecord($product, $xmlDate);
|
$date = $this->createDateRecord($product, $xmlDate);
|
||||||
$key = $hotelCode . $date['date_start'];
|
$key = $hotelCode . $date['date_start'];
|
||||||
@@ -378,18 +376,34 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
'important' => $product['important'],
|
'important' => $product['important'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$servicesBoard = $this->parseSelectionGroup($xmlDate, 'Leistungen Verpflegung');
|
$includedAccommodation = $this->parseSelectionGroup($xmlDate, 'Leistungen Übernachtung');
|
||||||
$skiPass = $this->parseSelectionGroup($xmlDate, 'Leistungen Skipass');
|
$includedSkiPass = $this->parseSelectionGroup($xmlDate, 'Leistungen Skipass');
|
||||||
$servicesIncluded = $this->parseSelectionGroup($xmlDate, 'Leistungen Sonstige');
|
$includedBoard = $this->parseSelectionGroup($xmlDate, 'Leistungen Verpflegung');
|
||||||
|
$includedTransportation = $this->parseSelectionGroup($xmlDate, 'Leistungen Transport');
|
||||||
|
$includedProgramme = $this->parseSelectionGroup($xmlDate, 'Leistungen Programm');
|
||||||
|
$includedPersonnel = $this->parseSelectionGroup($xmlDate, 'Leistungen Personal');
|
||||||
|
$includedEvents = $this->parseSelectionGroup($xmlDate, 'Leistungen Events');
|
||||||
|
$includedOther = $this->parseSelectionGroup($xmlDate, 'Leistungen Sonstige');
|
||||||
|
|
||||||
$date['services_included'] = serialize($this->combineServices($skiPass, $servicesBoard, $servicesIncluded));
|
$includedServices = [
|
||||||
|
...$includedAccommodation,
|
||||||
|
...$includedSkiPass,
|
||||||
|
...$includedTransportation,
|
||||||
|
...$includedBoard,
|
||||||
|
...$includedProgramme,
|
||||||
|
...$includedEvents,
|
||||||
|
...$includedPersonnel,
|
||||||
|
...$includedOther,
|
||||||
|
];
|
||||||
|
|
||||||
if ($servicesBoard) {
|
$date['services_included'] = serialize($includedServices);
|
||||||
$date['board'] = reset($servicesBoard);
|
|
||||||
$date['board_bus_pro_id'] = key($servicesBoard);
|
if ($includedBoard) {
|
||||||
|
$date['board'] = reset($includedBoard);
|
||||||
|
$date['board_bus_pro_id'] = key($includedBoard);
|
||||||
}
|
}
|
||||||
|
|
||||||
$skiPassIncluded = (int) (count($skiPass) > 0);
|
$skiPassIncluded = (int) (count($includedSkiPass) > 0);
|
||||||
$date['skipass_included'] = $skiPassIncluded;
|
$date['skipass_included'] = $skiPassIncluded;
|
||||||
|
|
||||||
$servicesTransportation = $this->parseService($xmlDate, 'lei_befoerderung');
|
$servicesTransportation = $this->parseService($xmlDate, 'lei_befoerderung');
|
||||||
@@ -440,9 +454,11 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
$date['services_general'] = serialize($combinedServices);
|
$date['services_general'] = serialize($combinedServices);
|
||||||
|
|
||||||
$pickups = [];
|
$pickups = [];
|
||||||
foreach ($xmlDate->xpath('zustiege/zustieg') as $pickup)
|
foreach ($xmlDate->xpath('zustiege/zustieg') as $pickup) {
|
||||||
{
|
|
||||||
$attributes = $pickup->attributes();
|
$attributes = $pickup->attributes();
|
||||||
|
if (null === $attributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$busProId = (int) $attributes['idbuspro'];
|
$busProId = (int) $attributes['idbuspro'];
|
||||||
if ($busProId === 0) {
|
if ($busProId === 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -459,34 +475,6 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $skiPass
|
|
||||||
* @param array $servicesBoard
|
|
||||||
* @param array $servicesIncluded
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function combineServices(array $skiPass, array $servicesBoard, array $servicesIncluded)
|
|
||||||
{
|
|
||||||
$combinedServices = [];
|
|
||||||
if ($servicesIncluded) {
|
|
||||||
foreach ($servicesIncluded as $service) {
|
|
||||||
$combinedServices[] = $service;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($skiPass) {
|
|
||||||
foreach ($skiPass as $service) {
|
|
||||||
$combinedServices[] = $service;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($servicesBoard) {
|
|
||||||
foreach ($servicesBoard as $service) {
|
|
||||||
$combinedServices[] = $service;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $combinedServices;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \SimpleXMLElement $xmlHotel
|
* @param \SimpleXMLElement $xmlHotel
|
||||||
* @param array $date
|
* @param array $date
|
||||||
@@ -510,8 +498,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
$hotelServices = $this->parseService($xmlHotel, 'lei_sonstiges', true);
|
$hotelServices = $this->parseService($xmlHotel, 'lei_sonstiges', true);
|
||||||
$this->addServices($generalServices, $services);
|
$this->addServices($generalServices, $services);
|
||||||
$this->addServices($hotelServices, $services);
|
$this->addServices($hotelServices, $services);
|
||||||
foreach ($services as $key => $list)
|
foreach ($services as $key => $list) {
|
||||||
{
|
|
||||||
uasort($list, function ($a, $b) {
|
uasort($list, function ($a, $b) {
|
||||||
return strcmp($a['label'], $b['label']);
|
return strcmp($a['label'], $b['label']);
|
||||||
});
|
});
|
||||||
@@ -550,8 +537,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
$boardCode = '';
|
$boardCode = '';
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
foreach ($xmlHotel->xpath('zimmer/preis') as $roomXml)
|
foreach ($xmlHotel->xpath('zimmer/preis') as $roomXml) {
|
||||||
{
|
|
||||||
$code = (string) $roomXml->attributes()['zimmercode'];
|
$code = (string) $roomXml->attributes()['zimmercode'];
|
||||||
|
|
||||||
if ($code === static::CODE_PSEUDOPRICE) {
|
if ($code === static::CODE_PSEUDOPRICE) {
|
||||||
@@ -639,10 +625,8 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
*/
|
*/
|
||||||
protected function determineDiscount(array $services)
|
protected function determineDiscount(array $services)
|
||||||
{
|
{
|
||||||
foreach ($services as $key => $section)
|
foreach ($services as $key => $section) {
|
||||||
{
|
foreach ($section as $service) {
|
||||||
foreach ($section as $service)
|
|
||||||
{
|
|
||||||
if ($service['price'] < 0) {
|
if ($service['price'] < 0) {
|
||||||
return (int) $service['price'];
|
return (int) $service['price'];
|
||||||
}
|
}
|
||||||
@@ -662,8 +646,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
$services = $xmlData->xpath($serviceLabel . '/leistung');
|
$services = $xmlData->xpath($serviceLabel . '/leistung');
|
||||||
foreach ($services as $service)
|
foreach ($services as $service) {
|
||||||
{
|
|
||||||
// Skip transportation service direction 'back'
|
// Skip transportation service direction 'back'
|
||||||
if ($service->richtung && (string) $service->richtung === 'RUECK') {
|
if ($service->richtung && (string) $service->richtung === 'RUECK') {
|
||||||
continue;
|
continue;
|
||||||
@@ -724,9 +707,11 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
$selectionGroup = $xmlDate->xpath('selektiongruppe[@bezeichnung="' . $label . '"]/selektion');
|
$selectionGroup = $xmlDate->xpath('selektiongruppe[@bezeichnung="' . $label . '"]/selektion');
|
||||||
foreach ($selectionGroup as $selection)
|
foreach ($selectionGroup as $selection) {
|
||||||
{
|
|
||||||
$attributes = $selection->attributes();
|
$attributes = $selection->attributes();
|
||||||
|
if (null === $attributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = (int) $attributes['idbuspro'];
|
$id = (int) $attributes['idbuspro'];
|
||||||
$data[$id] = (string) $attributes['bezeichnung'];
|
$data[$id] = (string) $attributes['bezeichnung'];
|
||||||
}
|
}
|
||||||
@@ -746,8 +731,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($services['BUS'] as $service)
|
foreach ($services['BUS'] as $service) {
|
||||||
{
|
|
||||||
$date['bus_available'] = 1;
|
$date['bus_available'] = 1;
|
||||||
$date['bus_price'] = (int) $service['price'];
|
$date['bus_price'] = (int) $service['price'];
|
||||||
$date['bus_included'] = (int) ((int) $service['price'] === 0);
|
$date['bus_included'] = (int) ((int) $service['price'] === 0);
|
||||||
@@ -758,8 +742,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
{
|
{
|
||||||
$sql = 'SELECT code, type FROM tx_epproducts_domain_model_roommapping';
|
$sql = 'SELECT code, type FROM tx_epproducts_domain_model_roommapping';
|
||||||
$roomMappings = $this->db->fetchAllAssociative($sql);
|
$roomMappings = $this->db->fetchAllAssociative($sql);
|
||||||
foreach ($roomMappings as $mapping)
|
foreach ($roomMappings as $mapping) {
|
||||||
{
|
|
||||||
$this->roomMappings[mb_strtolower($mapping['code'])] = $mapping['type'];
|
$this->roomMappings[mb_strtolower($mapping['code'])] = $mapping['type'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -783,8 +766,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
LEFT JOIN tx_epproducts_domain_model_hotel h ON u.uid = h.uid
|
LEFT JOIN tx_epproducts_domain_model_hotel h ON u.uid = h.uid
|
||||||
';
|
';
|
||||||
$rows = $this->db->fetchAllAssociative($sql);
|
$rows = $this->db->fetchAllAssociative($sql);
|
||||||
foreach ($rows as $row)
|
foreach ($rows as $row) {
|
||||||
{
|
|
||||||
$this->hotelMappings[$row['code']] = [
|
$this->hotelMappings[$row['code']] = [
|
||||||
'uid' => $row['uid'],
|
'uid' => $row['uid'],
|
||||||
'code' => $row['code'],
|
'code' => $row['code'],
|
||||||
@@ -827,8 +809,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
*/
|
*/
|
||||||
protected function addServices(array $services, array &$list)
|
protected function addServices(array $services, array &$list)
|
||||||
{
|
{
|
||||||
foreach ($services as $key => $section)
|
foreach ($services as $key => $section) {
|
||||||
{
|
|
||||||
if (!array_key_exists($key, $list)) {
|
if (!array_key_exists($key, $list)) {
|
||||||
$list[$key] = [];
|
$list[$key] = [];
|
||||||
}
|
}
|
||||||
@@ -845,9 +826,11 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($xmlData->zustieg as $entry)
|
foreach ($xmlData->zustieg as $entry) {
|
||||||
{
|
|
||||||
$attributes = $entry->attributes();
|
$attributes = $entry->attributes();
|
||||||
|
if (null === $attributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$idBusPro = (int) $attributes['idbuspro'];
|
$idBusPro = (int) $attributes['idbuspro'];
|
||||||
$this->pickups[$idBusPro] = [
|
$this->pickups[$idBusPro] = [
|
||||||
'city' => (string) $entry->ort,
|
'city' => (string) $entry->ort,
|
||||||
|
|||||||
Reference in New Issue
Block a user