Fix broken hotel teaser rendering in case of inavailability
This commit is contained in:
@@ -50,6 +50,33 @@ class HotelRepository extends AbstractRepository
|
|||||||
return $qb->execute()->fetch();
|
return $qb->execute()->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $hotelUid
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getDateIndependentSingleByUid($hotelUid)
|
||||||
|
{
|
||||||
|
$qb = DbUtility::getDbConnection()->createQueryBuilder();
|
||||||
|
$qb
|
||||||
|
->select(
|
||||||
|
'hotel.uid hotelUid', 'hotel.name hotelName', 'hotel.teaser hotelTeaser',
|
||||||
|
'hotel.category hotelCategory', 'hotel.detail_page hotelDetailPage',
|
||||||
|
'country.code countryCode', 'country.name country',
|
||||||
|
'region.name region'
|
||||||
|
)
|
||||||
|
->from('tx_epproducts_domain_model_hotel', 'hotel')
|
||||||
|
->leftJoin('hotel', 'tx_epproducts_domain_model_country', 'country', 'hotel.country = country.uid')
|
||||||
|
->leftJoin('hotel', 'tx_epproducts_domain_model_region', 'region', 'hotel.region = region.uid')
|
||||||
|
->where('hotel.uid = :hotelUid')
|
||||||
|
->andWhere('hotel.hidden = 0')
|
||||||
|
->andWhere('hotel.show_as_teaser = 1')
|
||||||
|
->andWhere('hotel.deleted = 0')
|
||||||
|
->setParameter('hotelUid', $hotelUid)
|
||||||
|
;
|
||||||
|
|
||||||
|
return $qb->execute()->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $productUid
|
* @param int $productUid
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ class HotelService implements SingletonInterface
|
|||||||
{
|
{
|
||||||
$hotelData = $this->hotelRepository->getSingleByUid($hotelUid);
|
$hotelData = $this->hotelRepository->getSingleByUid($hotelUid);
|
||||||
|
|
||||||
|
if ($hotelData === false) {
|
||||||
|
$hotelData = $this->hotelRepository->getDateIndependentSingleByUid($hotelUid);
|
||||||
|
$hotelData['available'] = -1; // TODO: Needs improvement. '-1' actually means: no price/date info available
|
||||||
|
}
|
||||||
|
|
||||||
$hotelCategory = array_key_exists($hotelData['hotelCategory'], Hotel::$categoryLabels) ?
|
$hotelCategory = array_key_exists($hotelData['hotelCategory'], Hotel::$categoryLabels) ?
|
||||||
Hotel::$categoryLabels[$hotelData['hotelCategory']] : null;
|
Hotel::$categoryLabels[$hotelData['hotelCategory']] : null;
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
</f:if>
|
</f:if>
|
||||||
<hr>
|
<hr>
|
||||||
{hotel.teaser -> f:format.crop(maxCharacters: settings.teaserTextMaxChars) -> f:format.html()}
|
{hotel.teaser -> f:format.crop(maxCharacters: settings.teaserTextMaxChars) -> f:format.html()}
|
||||||
<hr>
|
<f:if condition="{hotel.available} != -1">
|
||||||
<span class="teaserbox__price"><strong>{f:if(condition: '{hotel.available} > 0', then: 'ab {hotel.minPrice} €', else: 'ausgebucht')}</strong></span>
|
<hr>
|
||||||
|
<span class="teaserbox__price"><strong>{f:if(condition: '{hotel.available} > 0', then: 'ab {hotel.minPrice} €', else: 'ausgebucht')}</strong></span>
|
||||||
|
</f:if>
|
||||||
</div>
|
</div>
|
||||||
<button class="button button--full teaserbox__button">{f:translate(key: 'tx_eptheme.label.teaserbutton.default', extensionName: 'ep_theme')}</button>
|
<button class="button button--full teaserbox__button">{f:translate(key: 'tx_eptheme.label.teaserbutton.default', extensionName: 'ep_theme')}</button>
|
||||||
</f:link.page>
|
</f:link.page>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<div class="teaserbox__image">
|
<div class="teaserbox__image">
|
||||||
<img class="teaserbox__flag"
|
<img class="teaserbox__flag"
|
||||||
src="{f:uri.image(src: '{ep:flagiconSource(countryCode: hotel.country.code)}')}"
|
src="{f:uri.image(src: '{ep:flagiconSource(countryCode: hotel.country.code)}')}"
|
||||||
alt="{country: hotel.country.name}"/>
|
alt="{hotel.country.name}"/>
|
||||||
<f:render partial="TeaserImage" arguments="{image: hotel.images.0}"/>
|
<f:render partial="TeaserImage" arguments="{image: hotel.images.0}"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="teaserbox__main">
|
<div class="teaserbox__main">
|
||||||
|
|||||||
Reference in New Issue
Block a user