feat: don't import dates starting later than one year from now
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user