From e982796379189f2dee61ebee852ecb5f6fc60e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Mon, 4 May 2020 09:56:50 +0200 Subject: [PATCH] Sort groups price configs by date to determine earliest in js --- .../Classes/Controller/GroupsPriceController.php | 8 +++++++- .../ep_products/Classes/Controller/ProductController.php | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/GroupsPriceController.php b/public/typo3conf/ext/ep_products/Classes/Controller/GroupsPriceController.php index 796fb7aa..ca811aba 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/GroupsPriceController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/GroupsPriceController.php @@ -34,8 +34,14 @@ class GroupsPriceController extends ActionController { public function indexAction(Hotel $hotel) { + // Sort configs by date to properly determine earliest date in js component + $configs = $hotel->getGroupsPriceConfigs()->toArray(); + uasort($configs, function ($a, $b) { + return $a->getDateFrom() > $b->getDateFrom(); + }); + $this->view->assign('hotel', $hotel); - $this->view->assign('configs', json_encode($hotel->getGroupsPriceConfigs()->toArray())); + $this->view->assign('configs', json_encode($configs)); $this->view->assign('boards', json_encode($hotel->getGroupsPriceBoards()->toArray())); $this->view->assign('options', json_encode($hotel->getGroupsPriceOptions()->toArray())); } diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/ProductController.php b/public/typo3conf/ext/ep_products/Classes/Controller/ProductController.php index 78df9083..8c668657 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/ProductController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/ProductController.php @@ -143,7 +143,8 @@ class ProductController extends ActionController } // Use first hotel which should be the only one at this point if ($product->getHotels()->count() > 0) { - $hotel = reset($product->getHotels()->toArray()); + $hotels = $product->getHotels()->toArray(); + $hotel = reset($hotels); } }