From 88a48fa3a44ee16ff3e744d3b6b7b09dfda699dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Wed, 5 Feb 2020 12:41:32 +0100 Subject: [PATCH] Enable hiding of booking buttons in teasers and searchresult --- .../Classes/Domain/Repository/ProductRepository.php | 6 +++--- .../Classes/Service/DateImportService.php | 9 +++++---- .../ext/ep_products/Classes/Service/DateService.php | 12 ++++++++++-- .../Classes/Service/ProductDataService.php | 1 + .../Classes/Service/SearchResultService.php | 4 ++-- public/typo3conf/ext/ep_products/ext_tables.sql | 1 + .../Private/Assets/js/components/DatesTable.vue | 10 +++++----- .../Private/Assets/js/components/PriceTable.vue | 8 ++++---- .../Assets/js/components/SearchResultItem.vue | 4 ++-- .../Resources/Private/Language/de.locallang.xlf | 3 +++ .../Resources/Private/Language/locallang.xlf | 3 +++ .../Resources/Private/Partials/Product/Teaser.html | 7 ++++++- .../Private/Partials/Product/TeaserWide.html | 7 ++++++- 13 files changed, 51 insertions(+), 24 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php index 6ecc3ca8..b6adee38 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/ProductRepository.php @@ -100,7 +100,7 @@ class ProductRepository extends AbstractRepository 'date.board as board', 'date.product_fact as productFact', 'date.hotel_fact as hotelFact', 'date.region_fact as regionFact', 'date.services_included as servicesIncluded', 'date.min_price as minPrice', 'date.nights as nights', 'date.available as available', - 'date.pseudo_price as pseudoPrice' + 'date.pseudo_price as pseudoPrice', 'date.hide_booking_button as hideBookingButton' ) ->from('tx_epproducts_domain_model_date', 'date') ->leftJoin('date', 'tx_epproducts_domain_model_room', 'room', 'room.date = date.uid') @@ -154,8 +154,8 @@ class ProductRepository extends AbstractRepository 'date_start as dateStart', 'date_end as dateEnd', 'uid as dateUid', 'min_price as minPrice', 'pseudo_price as pseudoPrice', 'nights as nights', 'available as available', 'skipass_included as skipassIncluded', 'bus_included as busIncluded', - 'earlybird', 'new', 'daytrip', 'low_contingent as lowContingent', - 'concept_code as conceptCode', 'concept_name as conceptName', + 'earlybird', 'new', 'daytrip', 'hide_booking_button as hideBookingButton', + 'low_contingent as lowContingent', 'concept_code as conceptCode', 'concept_name as conceptName', 'board' ) ->from('tx_epproducts_domain_model_date', 'date') diff --git a/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php index dccf047d..7e710c75 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php @@ -232,7 +232,7 @@ class DateImportService implements SingletonInterface $dateCount = 0; $sql = ' - SELECT p.uid uid, p.daytrip daytrip, p.important important, p.name product_name, + SELECT p.uid uid, p.daytrip daytrip, p.hide_booking_button, p.important important, p.name product_name, p.searchable product_searchable, p.detail_page product_detail_page, p.keywords product_keywords, p.teaser product_teaser, p.feature product_feature, p.subline product_subline, p.country country, p.region region, p.city city, p.path_segment slug, @@ -365,6 +365,7 @@ class DateImportService implements SingletonInterface 'bus_pro_id' => $busProId, 'code' => $code, 'daytrip' => $product['daytrip'], + 'hide_booking_button' => $product['hide_booking_button'], 'important' => $product['important'], ]; @@ -619,7 +620,7 @@ class DateImportService implements SingletonInterface foreach ($section as $service) { if ($service['price'] < 0) { - return $service['price']; + return (int) $service['price']; } } } @@ -724,8 +725,8 @@ class DateImportService implements SingletonInterface foreach ($services['BUS'] as $service) { $date['bus_available'] = 1; - $date['bus_price'] = $service['price']; - $date['bus_included'] = ((int) $service['price'] === 0); + $date['bus_price'] = (int) $service['price']; + $date['bus_included'] = (int) ((int) $service['price'] === 0); } } diff --git a/public/typo3conf/ext/ep_products/Classes/Service/DateService.php b/public/typo3conf/ext/ep_products/Classes/Service/DateService.php index 44b0631c..2691e65f 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/DateService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/DateService.php @@ -107,6 +107,7 @@ class DateService implements SingletonInterface 'template' => $template, 'paCode' => $paCode, 'isDayTrip' => $product->isDaytrip(), + 'isHideBookingButton' => $product->getHideBookingButton(), ]); } @@ -148,6 +149,7 @@ class DateService implements SingletonInterface 'template' => $template, 'paCode' => $paCode, 'isDayTrip' => $product->isDaytrip(), + 'isHideBookingButton' => $product->getHideBookingButton(), ]); } @@ -259,9 +261,10 @@ class DateService implements SingletonInterface public function preprocessPriceTable(array $options) { $resolver = new OptionsResolver(); - $resolver->setDefined('paCode'); + $resolver->setDefined(['paCode', 'isDayTrip', 'isHideBookingButton']); $resolver->setRequired(['priceTableData', 'template']); $resolver->setDefault('isDayTrip', false); + $resolver->setDefault('isHideBookingButton', false); $resolvedOptions = $resolver->resolve($options); $priceTable = []; @@ -269,6 +272,7 @@ class DateService implements SingletonInterface $template = $resolvedOptions['template']; $paCode = $resolvedOptions['paCode']; $isDayTrip = $resolvedOptions['isDayTrip']; + $isHideBookingButton = $resolvedOptions['isHideBookingButton']; foreach ($priceTableData as $row) { @@ -299,6 +303,7 @@ class DateService implements SingletonInterface 'hotelBusProId' => $row['hotelBusProId'], 'roomBusProId' => $row['roomBusProId'], 'bookingUrl' => $bookingUrl, + 'isHideBookingButton' => $isHideBookingButton, ]; } @@ -312,9 +317,10 @@ class DateService implements SingletonInterface public function preprocessDateTable(array $options) { $resolver = new OptionsResolver(); - $resolver->setDefined('paCode'); + $resolver->setDefined(['paCode', 'isDayTrip', 'isHideBookingButton']); $resolver->setRequired(['dateTableData', 'template']); $resolver->setDefault('isDayTrip', false); + $resolver->setDefault('isHideBookingButton', false); $resolvedOptions = $resolver->resolve($options); $dateTable = []; @@ -323,6 +329,7 @@ class DateService implements SingletonInterface $template = $resolvedOptions['template']; $paCode = $resolvedOptions['paCode']; $isDayTrip = $resolvedOptions['isDayTrip']; + $isHideBookingButton = $resolvedOptions['isHideBookingButton']; foreach ($dateTableData as $row) { @@ -351,6 +358,7 @@ class DateService implements SingletonInterface 'dateServicesGeneral' => unserialize($row['dateServicesGeneral'], ['allowed_classes' => false]), 'available' => $row['available'], 'bookingUrl' => $bookingUrl, + 'isHideBookingButton' => $isHideBookingButton, ]; } diff --git a/public/typo3conf/ext/ep_products/Classes/Service/ProductDataService.php b/public/typo3conf/ext/ep_products/Classes/Service/ProductDataService.php index 83c6da30..184e0e53 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/ProductDataService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/ProductDataService.php @@ -197,6 +197,7 @@ class ProductDataService implements SingletonInterface 'earlybird' => $teaserData['earlybird'], 'new' => $teaserData['new'], 'daytrip' => $teaserData['daytrip'], + 'hideBookingButton' => $teaserData['hideBookingButton'], 'lowContingent' => $teaserData['lowContingent'], 'servicesIncluded' => unserialize($teaserData['servicesIncluded']), 'product' => [ diff --git a/public/typo3conf/ext/ep_products/Classes/Service/SearchResultService.php b/public/typo3conf/ext/ep_products/Classes/Service/SearchResultService.php index 95d16477..ea7703bf 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/SearchResultService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/SearchResultService.php @@ -107,8 +107,7 @@ class SearchResultService implements SingletonInterface // Use compound key, hotel is not unique $key = $row['hotelUid'] . ':' . $row['productUid']; - $hotelCategory = array_key_exists($row['hotelCategory'], Hotel::$categoryLabels) ? - Hotel::$categoryLabels[$row['hotelCategory']] : null; + $hotelCategory = Hotel::$categoryLabels[$row['hotelCategory']] ?? null; if (!array_key_exists($key, $items)) { $items[$key] = [ @@ -119,6 +118,7 @@ class SearchResultService implements SingletonInterface 'detailPageUri' => null, 'earlybird' => $row['earlybird'], 'daytrip' => $row['daytrip'], + 'hideBookingButton' => $row['hideBookingButton'], 'lowContingent' => $row['lowContingent'], 'servicesIncluded' => unserialize($row['servicesIncluded']), 'hotel' => [ diff --git a/public/typo3conf/ext/ep_products/ext_tables.sql b/public/typo3conf/ext/ep_products/ext_tables.sql index af1dd720..3be2bec4 100644 --- a/public/typo3conf/ext/ep_products/ext_tables.sql +++ b/public/typo3conf/ext/ep_products/ext_tables.sql @@ -120,6 +120,7 @@ CREATE TABLE tx_epproducts_domain_model_date available int(11) DEFAULT '0' NOT NULL, product int(11) unsigned DEFAULT '0', daytrip tinyint(1) unsigned DEFAULT '0' NOT NULL, + hide_booking_button tinyint(1) unsigned DEFAULT '0' NOT NULL, important tinyint(1) unsigned DEFAULT '0' NOT NULL, product_name varchar(255) DEFAULT '' NOT NULL, product_subline varchar(255) DEFAULT '' NOT NULL, diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/DatesTable.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/DatesTable.vue index d5b660e9..41f9f21e 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/DatesTable.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/DatesTable.vue @@ -36,7 +36,7 @@ -