From 34f190f4695337f8e7747d14e3dd5e268973163f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 23 Jan 2026 15:35:24 +0100 Subject: [PATCH] fix: don't normalize hotel and product codes when fetching cms data --- src/Service/BookingSummaryDataService.php | 16 +++++------- src/Service/CmsDataService.php | 30 +---------------------- 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/src/Service/BookingSummaryDataService.php b/src/Service/BookingSummaryDataService.php index 627ebf2..3d25635 100644 --- a/src/Service/BookingSummaryDataService.php +++ b/src/Service/BookingSummaryDataService.php @@ -135,29 +135,26 @@ class BookingSummaryDataService /** * Fetches hotel display data combining local base hotel data with CMS images. * - * Uses normalized codes (first 3 characters, or characters 4-6 for 'SER' codes) - * for both local hotel lookup and CMS image retrieval. Local hotel data provides - * name and address while CMS provides images as a nice-to-have enhancement. + * Local hotel data provides name and address while CMS provides images + * as a nice-to-have enhancement. * * Data is cached for 1 hour. This method can be called early in the booking * flow to warm the cache. */ public function getCmsDataForProduct(?string $productCode, ?string $hotelCode): ?array { - $normalizedHotelCode = $this->cmsDataService->normalizeCode($hotelCode); - - if (null === $normalizedHotelCode) { + if (null === $hotelCode) { return null; } - $cacheKey = sprintf('cms_data.%s.%s', $normalizedHotelCode, $normalizedHotelCode); + $cacheKey = sprintf('cms_data.%s.%s', $productCode, $hotelCode); try { - return $this->cache->get($cacheKey, function (ItemInterface $item) use ($productCode, $hotelCode, $normalizedHotelCode) { + return $this->cache->get($cacheKey, function (ItemInterface $item) use ($productCode, $hotelCode) { $item->expiresAfter(3600); // 1 hour // Fetch base hotel from local BusProNet data - $baseHotel = $this->hotelLoader->loadByCode($normalizedHotelCode); + $baseHotel = $this->hotelLoader->loadByCode($hotelCode); // Fetch CMS images (nice to have) $images = $this->cmsDataService->getProductImages($productCode, $hotelCode); @@ -175,7 +172,6 @@ class BookingSummaryDataService $this->logger->error('Failed to fetch hotel display data', [ 'product_code' => $productCode, 'hotel_code' => $hotelCode, - 'normalized_hotel_code' => $normalizedHotelCode, 'exception' => $e->getMessage(), ]); diff --git a/src/Service/CmsDataService.php b/src/Service/CmsDataService.php index a9d453a..10c4adb 100644 --- a/src/Service/CmsDataService.php +++ b/src/Service/CmsDataService.php @@ -11,42 +11,14 @@ class CmsDataService { } - /** - * Normalizes a product or hotel code for CMS lookup. - * - * Returns the first 3 characters of the code, except for codes - * starting with 'SER' where characters 4-6 are returned instead. - */ - public function normalizeCode(?string $code): ?string - { - if (null === $code || 3 > strlen($code)) { - return null; - } - - if (str_starts_with($code, 'SER') && 6 <= strlen($code)) { - return substr($code, 3, 3); - } - - return substr($code, 0, 3); - } - /** * Fetches only the hotel images from the CMS. * - * The product code is normalized for CMS lookup while the hotel code - * is passed as-is for better matching results. - * * @return array|null The images array or null if unavailable */ public function getProductImages(string $productCode, ?string $hotelCode = null): ?array { - $normalizedProduct = $this->normalizeCode($productCode); - - if (null === $normalizedProduct) { - return null; - } - - $result = $this->getProductDetails($normalizedProduct, $hotelCode); + $result = $this->getProductDetails($productCode, $hotelCode); if (true === isset($result['success']) && false === $result['success']) { return null;