fix: match API whitespace handling and skip matchcodes of hidden hotels

This commit is contained in:
fromme committed 2026-09-30 14:57:39 +02:00
1 parent 27832d6548
commit c2dc88b8ab
2 files changed
+13 -4

No files matched your search

@@ -827,7 +827,9 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
WHERE hotel.code != "" AND hotel.deleted = 0 AND hotel.hidden = 0
UNION SELECT matchcode.code code, matchcode.entity uid
FROM tx_epproducts_domain_model_matchcode matchcode
INNER JOIN tx_epproducts_domain_model_hotel matchcode_hotel ON matchcode.entity = matchcode_hotel.uid
WHERE matchcode.deleted = 0 AND matchcode.hidden = 0
AND matchcode_hotel.deleted = 0 AND matchcode_hotel.hidden = 0
ORDER BY code
) u
LEFT JOIN tx_epproducts_domain_model_hotel h ON u.uid = h.uid
@@ -13,7 +13,9 @@ use Psr\Log\NullLogger;
*
* Nothing is filtered or rewritten here: every display rule stays in
* DateImportService. Prices are parsed from the German format, and a price the
* source does not state is null.
* source does not state is null. Like the API, service labels and pickup
* cities and streets are trimmed with inner whitespace collapsed; every other
* text is passed on verbatim.
*/
final class XmlProductReader implements \IteratorAggregate
{
@@ -197,7 +199,7 @@ final class XmlProductReader implements \IteratorAggregate
$services[] = [
'busProId' => (int) $xmlService['idbuspro'],
'subType' => (string) $xmlService['unterart'],
'label' => (string) $xmlService->text,
'label' => $this->normalizeWhitespace((string) $xmlService->text),
'price' => $this->parsePrice((string) $xmlService->preis),
'status' => (string) $xmlService->status,
'direction' => $direction === '' ? null : $direction,
@@ -316,14 +318,19 @@ final class XmlProductReader implements \IteratorAggregate
foreach ($xmlData->zustieg as $xmlPickup) {
$pickups[(int) $xmlPickup['idbuspro']] = [
'code' => (string) $xmlPickup['code'],
'city' => (string) $xmlPickup->ort,
'street' => (string) $xmlPickup->strasse,
'city' => $this->normalizeWhitespace((string) $xmlPickup->ort),
'street' => $this->normalizeWhitespace((string) $xmlPickup->strasse),
];
}
return $pickups;
}
private function normalizeWhitespace(string $value): string
{
return trim((string) preg_replace('/\s+/u', ' ', $value));
}
private function parseDate(string $value): ?\DateTimeImmutable
{
$date = \DateTimeImmutable::createFromFormat('!d.m.Y', trim($value), $this->timezone);