fix: /api/product no longer returns another product for some codes

The product lookup also matched hotel aliases (matchcodes), joined on
the product uid. Matchcodes only exist for hotels, so a hotel alias
equal to the requested code matched whatever product had that hotel's
uid. With no ordering, the database picked one of the rows: locally
DPWGRU3 returned SnowZone and KHHMP returned Hotel Terrace instead of
Roncalli Düren and Gasthof Heidelberg. The other 313 product codes
return the same response as before.

Products are looked up by code only. Some codes exist on two products
(e.g. MVKPGW); ordering by uid makes the result deterministic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5.5 committed 2026-10-29 15:46:55 +01:00
1 parent 2bd663a9bf
commit 4cefbce87e
1 file changed
+2 -2
@@ -163,9 +163,9 @@ class ApiMiddleware implements MiddlewareInterface
->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_city', 'city', 'product.city = city.uid')
->leftJoin('product', 'tx_epproducts_domain_model_matchcode', 'matchcode', 'product.uid = matchcode.entity AND matchcode.entity_type="hotel"')
->where($queryBuilder->expr()->eq('product.code', $queryBuilder->createNamedParameter($productCode)))
->orWhere($queryBuilder->expr()->eq('matchcode.code', $queryBuilder->createNamedParameter($productCode)))->setMaxResults(1)->executeQuery()
->orderBy('product.uid')
->setMaxResults(1)->executeQuery()
->fetchAssociative()
;