From 4596b88bee140deca085d326bca232d2ab4c5d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 20 Nov 2025 19:02:17 +0100 Subject: [PATCH] feat: adjust data returned by api calls for myep --- .../Middleware/ProductApiMiddleware.php | 58 +++++++++---------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Middleware/ProductApiMiddleware.php b/public/typo3conf/ext/ep_products/Classes/Middleware/ProductApiMiddleware.php index c1f58c6f..d812c212 100644 --- a/public/typo3conf/ext/ep_products/Classes/Middleware/ProductApiMiddleware.php +++ b/public/typo3conf/ext/ep_products/Classes/Middleware/ProductApiMiddleware.php @@ -53,26 +53,21 @@ class ProductApiMiddleware implements MiddlewareInterface $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tx_epproducts_domain_model_product'); - $product = $queryBuilder + $data = $queryBuilder ->select( - 'uid', - 'name', - 'code', - 'headline', - 'teaser', - 'teaser_long', - 'concept_description', - 'board_description', - 'programme_description', - 'included_services', - 'additional_services', - 'ski_pass_alt_title', - 'ski_pass_description' + 'product.name as productName', + 'product.code as productCode', + 'country.name as countryName', + 'region.name as regionName', + 'city.name as cityName', ) - ->from('tx_epproducts_domain_model_product') + ->from('tx_epproducts_domain_model_product', 'product') + ->leftJoin('product', 'tx_epproducts_domain_model_country', 'country', 'product.country = country.uid') + ->leftJoin('product', 'tx_epproducts_domain_model_region', 'region', 'product.region = region.uid') + ->leftJoin('product', 'tx_epproducts_domain_model_city', 'city', 'product.city = city.uid') ->where( $queryBuilder->expr()->eq( - 'code', + 'product.code', $queryBuilder->createNamedParameter($productCode) ) ) @@ -81,27 +76,28 @@ class ProductApiMiddleware implements MiddlewareInterface ->fetchAssociative() ; - if (false === $product) { + if (false === $data) { return null; } $images = GeneralUtility::makeInstance(ProductImageService::class) - ->getImages((int) $product['uid']); + ->getImages((int) $data['uid']); return [ - 'name' => $product['name'], - 'code' => $product['code'], - 'headline' => $product['headline'], - 'teaser' => $product['teaser'], - 'teaserLong' => $product['teaser_long'], - 'conceptDescription' => $product['concept_description'], - 'boardDescription' => $product['board_description'], - 'programmeDescription' => $product['programme_description'], - 'includedServices' => $product['included_services'], - 'additionalServices' => $product['additional_services'], - 'skiPassAltTitle' => $product['ski_pass_alt_title'], - 'skiPassDescription' => $product['ski_pass_description'], - 'images' => $images, + 'product' => [ + 'name' => $data['productName'], + 'code' => $data['productCode'], + 'images' => $images, + ], + 'country' => [ + 'name' => $data['countryName'], + ], + 'region' => [ + 'name' => $data['regionName'], + ], + 'city' => [ + 'name' => $data['cityName'], + ], ]; }