diff --git a/web/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php b/web/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php index ef0a6e61..3cb4a760 100644 --- a/web/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php +++ b/web/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php @@ -167,21 +167,28 @@ class ContingentImportService implements SingletonInterface protected function parseContingent(\SimpleXMLElement $xmlContingent) { $hotelCode = (string) $xmlContingent['code']; - $sql = 'SELECT uid, code, groupsch_id FROM tx_epproducts_domain_model_hotel WHERE deleted = 0 AND hidden = 0 AND code = :code'; + $sql = 'SELECT h.uid uid, h.groupsch_id groupsch_id + FROM tx_epproducts_domain_model_hotel h + LEFT JOIN tx_epproducts_domain_model_matchcode m ON (h.uid = m.entity AND m.entity_type = "hotel") + WHERE h.deleted = 0 AND h.hidden = 0 AND h.code = :code OR m.code = :code + LIMIT 0,1'; $hotelData = $this->db->fetchAssoc($sql, ['code' => $hotelCode]); // Skip import in case hotel can't be found if ($hotelData === false) { $this->logger->warning('hotel not found', ['code' => $hotelCode]); return 0; - } elseif (empty($xmlContingent->kapazitaeten)) { + } + + if ($xmlContingent->kapazitaeten === null) { $this->logger->warning('hotel has no contingents', ['code' => $hotelCode]); return 0; - } else { - $hotelData['busProId'] = (string) $xmlContingent['idbuspro']; - $roomTypes = $this->parseRoomTypes($xmlContingent->unterbringungen); - return $this->parseRooms($xmlContingent->kapazitaeten, $hotelData, $roomTypes); } + + $hotelData['busProId'] = (string) $xmlContingent['idbuspro']; + $hotelData['code'] = $hotelCode; + $roomTypes = $this->parseRoomTypes($xmlContingent->unterbringungen); + return $this->parseRooms($xmlContingent->kapazitaeten, $hotelData, $roomTypes); } /**