29 public static function fetchCollection($query)
31 $select = $query->getSelect();
33 $query->setSelect([
new ExpressionField(
'DISTINCT_ID',
'DISTINCT %s',
'ID')]);
34 $query->addGroup(
'ID');
39 foreach ($query->exec()->fetchAll() as $row)
41 $ids[] = $row[
'DISTINCT_ID'];
45 $dataClass = $query->getEntity()->getDataClass();
46 $elements = $dataClass::createCollection();
51 $query = $dataClass::query();
53 $query->setSelect($select);
55 $query->whereIn(
'ID', $ids);
59 foreach ($query->fetchCollection() as $elementObject)
62 $resultElements[$elementObject->getId()] = $elementObject;
68 $elements->sysAddActual($resultElements[$id]);