From 02580437708788d91df193fc6f9a38d0194a8428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 27 Jun 2025 09:30:19 +0200 Subject: [PATCH] fix: consider additional hotelcodes for contingent calendar, add index --- .../Repository/ContingentRepository.php | 30 ++++++++----------- .../typo3conf/ext/ep_products/ext_tables.sql | 13 ++++---- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php index 2ccfd75a..88d1ca26 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php @@ -58,13 +58,16 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa $qb = $this->getDbConnection()->createQueryBuilder(); $qb - ->select('status as status', 'date as date', 'min_price as minPrice', 'pax', 'available', 'room_code') - ->from('tx_epproducts_domain_model_contingent') - ->where('hotel = :hotelUid') - ->andWhere('date >= :dateFrom') + ->select('c.status as status', 'c.date as date', 'c.min_price as minPrice', 'c.pax', 'c.available', 'c.room_code') + ->innerJoin('c', 'tx_epproducts_domain_model_hotel', 'h', 'c.hotel = h.uid') + ->leftJoin('c', 'tx_epproducts_domain_model_matchcode', 'm', 'h.uid = m.entity AND m.entity_type = "hotel"') + ->from('tx_epproducts_domain_model_contingent', 'c') + ->where('c.hotel = :hotelUid') + ->orWhere('c.hotel_code = m.code') + ->andWhere('c.date >= :dateFrom') ->setParameter('hotelUid', $hotel->getUid()) ->setParameter('dateFrom', $begin->format('Y-m-d')) - ->orderBy('date') + ->orderBy('c.date') ; if (null !== $end) { @@ -78,8 +81,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa $dates = []; - foreach ($result as $row) - { + foreach ($result as $row) { if (!\array_key_exists($row['date'], $dates)) { $dates[$row['date']] = [ 'status' => Contingent::STATUS_OK, @@ -88,7 +90,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa 'available' => 0, ]; } - if ($row['status'] !== Contingent::STATUS_OK) { + if (Contingent::STATUS_OK !== $row['status']) { $dates[$row['date']]['status'] = $row['status']; } if ('BelKal' !== $row['room_code']) { @@ -99,8 +101,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa $events = []; - foreach ($dates as $row) - { + foreach ($dates as $row) { $row['hotel'] = $hotel; $events[] = Contingent::fromArray($row); } @@ -109,9 +110,8 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa } /** - * @param Hotel $hotel - * @param Product $product * @return array + * * @throws DBALException */ public function getAvailableContingents(Hotel $hotel, Product $product) @@ -140,11 +140,8 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa } /** - * @param string $dateFrom - * @param string $dateTo - * @param Hotel $hotel - * @param Product $product * @return array + * * @throws DBALException */ public function getAvailableRooms(string $dateFrom, string $dateTo, Hotel $hotel, Product $product) @@ -178,5 +175,4 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa return $qb->execute()->fetchAllAssociative(); } - } diff --git a/public/typo3conf/ext/ep_products/ext_tables.sql b/public/typo3conf/ext/ep_products/ext_tables.sql index dfb2ccee..c57f0283 100644 --- a/public/typo3conf/ext/ep_products/ext_tables.sql +++ b/public/typo3conf/ext/ep_products/ext_tables.sql @@ -285,8 +285,8 @@ CREATE TABLE tx_epproducts_domain_model_hotel PRIMARY KEY (uid), KEY parent (pid), KEY t3ver_oid (t3ver_oid, t3ver_wsid), - KEY language (l10n_parent, sys_language_uid) - + KEY language (l10n_parent, sys_language_uid), + KEY idx_hotel_uid (uid, deleted, hidden, starttime, endtime) ); # @@ -859,8 +859,8 @@ CREATE TABLE tx_epproducts_domain_model_matchcode PRIMARY KEY (uid), KEY parent (pid), KEY t3ver_oid (t3ver_oid, t3ver_wsid), - KEY language (l10n_parent, sys_language_uid) - + KEY language (l10n_parent, sys_language_uid), + KEY idx_matchcode_entity_type (entity, entity_type, deleted, hidden, starttime, endtime) ); # @@ -1187,8 +1187,9 @@ CREATE TABLE tx_epproducts_domain_model_contingent KEY parent (pid), KEY t3ver_oid (t3ver_oid, t3ver_wsid), KEY language (l10n_parent, sys_language_uid), - KEY groups (date, hotel) - + KEY groups (date, hotel), + KEY idx_contingent_hotel_date (hotel, date, deleted, hidden, starttime, endtime), + KEY idx_contingent_hotel_code_date (hotel_code, date, deleted, hidden, starttime, endtime) ); #