Fix issue with non-bookable hotel in list on product detail page
This commit is contained in:
@@ -195,18 +195,7 @@ class ProductController extends ActionController
|
||||
)
|
||||
{
|
||||
$hotels = $this->hotelService->getList($product);
|
||||
// Forward to detail view in case there's only one hotel
|
||||
if (count($hotels) === 1) {
|
||||
$hotel = reset($hotels);
|
||||
$arguments = [
|
||||
'product' => $product,
|
||||
'hotel' => $hotel,
|
||||
'filterSettings' => $filterSettings,
|
||||
'referringPageUid' => $referringPageUid,
|
||||
];
|
||||
$this->forward('detail', null, null, $arguments);
|
||||
}
|
||||
list($productDateRangeFrom, $productDateRangeTo) = $this->filterService->getProductDateRange($product, $filterSettings);
|
||||
list ($productDateRangeFrom, $productDateRangeTo) = $this->filterService->getProductDateRange($product, $filterSettings);
|
||||
$this->view->assignMultiple([
|
||||
'filterSettings' => $filterSettings,
|
||||
'hotels' => $hotels,
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace EP\EpProducts\Domain\Repository;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use EP\EpProducts\Domain\Model\Hotel;
|
||||
use EP\EpProducts\Utility\DbUtility;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class HotelRepository extends AbstractRepository
|
||||
{
|
||||
@@ -98,41 +99,45 @@ class HotelRepository extends AbstractRepository
|
||||
*/
|
||||
public function getListByCriteria(array $criteria)
|
||||
{
|
||||
$optionsResolver = new OptionsResolver();
|
||||
$optionsResolver->setDefined(['regionUid', 'countryUid', 'conceptUid', 'productUid', 'category', 'type']);
|
||||
$resolvedCriteria = $optionsResolver->resolve($criteria);
|
||||
|
||||
$qb = $this->getQueryBuilder();
|
||||
if ($criteria['regionUid']) {
|
||||
if ($resolvedCriteria['regionUid']) {
|
||||
$qb
|
||||
->andWhere('date.region = :regionUid')
|
||||
->setParameter('regionUid', $criteria['regionUid'])
|
||||
->setParameter('regionUid', $resolvedCriteria['regionUid'])
|
||||
;
|
||||
}
|
||||
if ($criteria['countryUid']) {
|
||||
if ($resolvedCriteria['countryUid']) {
|
||||
$qb
|
||||
->andWhere('date.country = :countryUid')
|
||||
->setParameter('countryUid', $criteria['countryUid'])
|
||||
->setParameter('countryUid', $resolvedCriteria['countryUid'])
|
||||
;
|
||||
}
|
||||
if ($criteria['conceptUid']) {
|
||||
if ($resolvedCriteria['conceptUid']) {
|
||||
$qb
|
||||
->andWhere('date.concept = :conceptUid')
|
||||
->setParameter('conceptUid', $criteria['conceptUid'])
|
||||
->setParameter('conceptUid', $resolvedCriteria['conceptUid'])
|
||||
;
|
||||
}
|
||||
if ($criteria['productUid']) {
|
||||
if ($resolvedCriteria['productUid']) {
|
||||
$qb
|
||||
->andWhere('date.product = :productUid')
|
||||
->setParameter('productUid', $criteria['productUid'])
|
||||
->setParameter('productUid', $resolvedCriteria['productUid'])
|
||||
;
|
||||
}
|
||||
if ($criteria['category']) {
|
||||
if ($resolvedCriteria['category']) {
|
||||
$qb
|
||||
->andWhere('date.hotel_category = :category')
|
||||
->setParameter('category', $criteria['category'])
|
||||
->setParameter('category', $resolvedCriteria['category'])
|
||||
;
|
||||
}
|
||||
if ($criteria['type']) {
|
||||
if ($resolvedCriteria['type']) {
|
||||
$qb
|
||||
->andWhere('date.hotel_type = :type')
|
||||
->setParameter('type', $criteria['type'])
|
||||
->setParameter('type', $resolvedCriteria['type'])
|
||||
;
|
||||
}
|
||||
|
||||
@@ -146,6 +151,10 @@ class HotelRepository extends AbstractRepository
|
||||
*/
|
||||
public function getDateIndependentListByCriteria(array $criteria, array $excludedHotelUids = [])
|
||||
{
|
||||
$optionsResolver = new OptionsResolver();
|
||||
$optionsResolver->setDefined(['productUid', 'countryUid', 'regionUid', 'category', 'type']);
|
||||
$resolvedCriteria = $optionsResolver->resolve($criteria);
|
||||
|
||||
$qb = DbUtility::getDbConnection()->createQueryBuilder();
|
||||
$qb
|
||||
->select(
|
||||
@@ -170,35 +179,35 @@ class HotelRepository extends AbstractRepository
|
||||
->setParameter('excludedHotelUids', $excludedHotelUids, Connection::PARAM_INT_ARRAY)
|
||||
;
|
||||
}
|
||||
if ($criteria['productUid']) {
|
||||
if ($resolvedCriteria['productUid']) {
|
||||
$qb
|
||||
->innerJoin('hotel', 'tx_epproducts_product_hotel_mm', 'mm', 'hotel.uid = mm.uid_foreign')
|
||||
->andWhere('mm.uid_local = :product')
|
||||
->setParameter('product', $criteria['productUid'])
|
||||
->setParameter('product', $resolvedCriteria['productUid'])
|
||||
;
|
||||
}
|
||||
if ($criteria['countryUid']) {
|
||||
if ($resolvedCriteria['countryUid']) {
|
||||
$qb
|
||||
->andWhere('hotel.country = :country')
|
||||
->setParameter('country', $criteria['countryUid'])
|
||||
->setParameter('country', $resolvedCriteria['countryUid'])
|
||||
;
|
||||
}
|
||||
if ($criteria['regionUid']) {
|
||||
if ($resolvedCriteria['regionUid']) {
|
||||
$qb
|
||||
->andWhere('hotel.region = :region')
|
||||
->setParameter('region', $criteria['regionUid'])
|
||||
->setParameter('region', $resolvedCriteria['regionUid'])
|
||||
;
|
||||
}
|
||||
if ($criteria['category']) {
|
||||
if ($resolvedCriteria['category']) {
|
||||
$qb
|
||||
->andWhere('hotel.category = :category')
|
||||
->setParameter('category', $criteria['category'])
|
||||
->setParameter('category', $resolvedCriteria['category'])
|
||||
;
|
||||
}
|
||||
if ($criteria['type']) {
|
||||
if ($resolvedCriteria['type']) {
|
||||
$qb
|
||||
->andWhere('hotel.type = :type')
|
||||
->setParameter('type', $criteria['type'])
|
||||
->setParameter('type', $resolvedCriteria['type'])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user