diff --git a/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php index 230f49c2..382ae083 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php @@ -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