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 4fb3d335..04458b57 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ContingentRepository.php @@ -46,32 +46,25 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa public function getEvents(\DateTime $dateFrom, \DateTime $dateTo = null, array $options = []) { $optionsResolver = new OptionsResolver(); + $optionsResolver->setRequired(['hotelCode']); $optionsResolver->setDefined(['hotel']); + $optionsResolver->setDefaults(['hotel' => null]); $optionsResolver->setAllowedTypes('hotel', Hotel::class); $resolvedOptions = $optionsResolver->resolve($options); + $hotel = $resolvedOptions['hotel']; + $hotelCode = $resolvedOptions['hotelCode']; + $qb = $this->getDbConnection()->createQueryBuilder(); $qb ->select('status as status', 'date as date', 'min_price as minPrice', 'pax', 'available') ->from('tx_epproducts_domain_model_contingent') - ->orderBy('date') - ; - - $hotel = null; - - if ($resolvedOptions['hotel']) { - /** @var Hotel $hotel */ - $hotel = $resolvedOptions['hotel']; - $qb - ->where('hotel = :hotel') - ->setParameter('hotel', $hotel->getUid()) - ; - } - - $qb + ->where('hotel_code = :hotelCode') ->andWhere('date >= :dateFrom') + ->setParameter('hotelCode', $hotelCode) ->setParameter('dateFrom', $dateFrom->format('Y-m-d')) + ->orderBy('date') ; if (null !== $dateTo) { @@ -81,7 +74,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa ; } - $result = $qb->execute()->fetchAll(); + $result = $qb->execute()->fetchAllAssociative(); $dates = []; @@ -145,7 +138,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa ->orderBy('c.date') ; - return $qb->execute()->fetchAll(); + return $qb->execute()->fetchAllAssociative(); } /** @@ -185,7 +178,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa ->addOrderBy('c.min_price') ; - return $qb->execute()->fetchAll(); + return $qb->execute()->fetchAllAssociative(); } } diff --git a/public/typo3conf/ext/ep_products/Classes/Service/GroupsSwissService.php b/public/typo3conf/ext/ep_products/Classes/Service/GroupsSwissService.php index fbeb414e..44d5c1d5 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/GroupsSwissService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/GroupsSwissService.php @@ -94,15 +94,20 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface { $range = Period::after(new \DateTime('now'), '1 year'); - foreach ($this->apiKeys as $hotelUid => $config) { - /** @var Hotel $hotel */ - $hotel = $this->hotelRepository->findByUid($hotelUid); + foreach ($this->apiKeys as $config) { - if (null === $hotel) { - $this->logger->error(sprintf('Hotel with uid %d not found', $hotelUid)); + $hotelCode = $config['hotelCode']; + + $result = $this->hotelRepository->findByCode($hotelCode); + + if (null === $result) { + $this->logger->error(sprintf('Hotel with code %s not found', $hotelCode)); continue; } + /** @var Hotel $hotel */ + $hotel = $result->getFirst(); + $this->logger->info(sprintf( 'Publishing availabilities for hotel %s', preg_replace( '/[\r\n]/', '', $hotel->getName()) @@ -112,7 +117,7 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface $events = $this->contingentRepository->getEvents( \DateTime::createFromImmutable($range->getStartDate()), \DateTime::createFromImmutable($range->getEndDate()), - ['hotel' => $hotel] + ['hotel' => $hotel, 'hotelCode' => $hotelCode] ); } catch (DBALException $e) { @@ -216,7 +221,8 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface ); try { - $this->httpClient->request('GET', $url); + $foo = 1; +// $this->httpClient->request('GET', $url); } catch (TransportExceptionInterface $e) { $this->logger->error(sprintf('A problem occured: %s', $e->getMessage())); } diff --git a/public/typo3conf/ext/ep_products/Classes/Service/IcalService.php b/public/typo3conf/ext/ep_products/Classes/Service/IcalService.php index be97b8a1..fde65f31 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/IcalService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/IcalService.php @@ -65,7 +65,7 @@ class IcalService implements SingletonInterface $events = $this->contingentRepository->getEvents( $now, null, - ['hotel' => $hotel] + ['hotel' => $hotel, 'hotelCode' => $hotel->getCode()] ); } catch (DBALException $e) { diff --git a/public/typo3conf/ext/ep_products/Configuration/TypoScript/setup.typoscript b/public/typo3conf/ext/ep_products/Configuration/TypoScript/setup.typoscript index 0fe602fa..1de7e329 100644 --- a/public/typo3conf/ext/ep_products/Configuration/TypoScript/setup.typoscript +++ b/public/typo3conf/ext/ep_products/Configuration/TypoScript/setup.typoscript @@ -67,36 +67,37 @@ plugin.tx_epproducts { groupsSwissApiKeys { # Spinabad 7 { + hotelCode = DGS number = 9849 key = a8b504ab2784446cbf73b8b1f6777f43 } # Waldschlössli 6 { + hotelCode = DPW number = 9658 key = f757b34dc3ac4a158257cf12c9ce69e1 } # Jenatsch 37 { + hotelCode = LPJNEU number = 9703 key = 52c314a88a434b359717115db992d20d } # Schweizerhaus 5 { + hotelCode = DKS number = 9850 key = 4a955b23158d40c583b2892a18aa1043 } - # Astoria - 74 { - number = 632795 - key = 7002bbee9fab4985b1caccabb6f6cab5 - } # Klein Tirol 65 { + hotelCode = MVK number = 668904 key = e9d86dbc465848d7a0b68df14e3e482f } # Weissfluh 131 { + hotelCode = DWW21/22 number = 961523 key = 6a22585d23184f2090bd7110aa9b60f3 }