From 731273c296919987141160186c0c7801c3c33ccb Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 12 Mar 2020 17:02:24 +0200 Subject: [PATCH] select manager: default order by to select --- application/Espo/Core/SelectManagers/Base.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php index ab107de181..c5fcb27df5 100644 --- a/application/Espo/Core/SelectManagers/Base.php +++ b/application/Espo/Core/SelectManagers/Base.php @@ -2661,9 +2661,9 @@ class Base } } - if (!empty($params['orderBy'])) { - $sortByField = $params['orderBy']; + $sortByField = $params['orderBy'] ?? $this->getMetadata()->get(['entityDefs', $this->entityType, 'collection', 'orderBy']); + if ($sortByField) { $sortByAttributeList = $this->getFieldManagerUtil()->getAttributeList($this->getEntityType(), $sortByField); foreach ($sortByAttributeList as $attribute) { if (!in_array($attribute, $attributeList) && $seed->hasAttribute($attribute)) {