feat: don't import dates starting later than one year from now

This commit is contained in:
Björn Fromme
2025-01-09 09:47:09 +01:00
parent 06be7181c7
commit c7a964b24b
@@ -264,8 +264,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
$product['bus_pro_id'] = $busProId;
$product['product_fact'] = $this->getTopFactForRecord('tx_epproducts_product_fact_mm', $product['uid']);
$product['region_fact'] = $this->getTopFactForRecord('tx_epproducts_region_fact_mm', $product['region']);
foreach ($xmlProduct->termin as $xmlDate)
{
foreach ($xmlProduct->termin as $xmlDate) {
$dateCount += $this->parseDates($xmlDate, $product);
}
}
@@ -281,9 +280,18 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
protected function parseDates(\SimpleXMLElement $xmlDate, array $product): int
{
$dateCount = 0;
$earliestDate = new \DateTimeImmutable('next year');
foreach ($xmlDate->hotel as $xmlHotel) {
$hotelCode = (string) $xmlHotel->attributes()['code'];
// don't import dates starting later than one year from now
$dateStart = \DateTime::createFromFormat('d.m.Y', (string) $xmlDate->attributes()['termin']);
if ($dateStart > $earliestDate) {
continue;
}
$date = $this->createDateRecord($product, $xmlDate);
$hotelCode = (string) $xmlHotel->attributes()['code'];
$key = $hotelCode . $date['date_start'];
// Import daytrip dates only once per hotel as room information is taken