/** * {@inheritdoc} */ public function getResults() { $options = ['locale_code' => $this->getConfiguration('locale_code'), 'scope_code' => $this->getConfiguration('scope_code'), 'attributes_configuration' => $this->getConfiguration('attributes_configuration'), 'current_group_id' => $this->getConfiguration('current_group_id', false), 'association_type_id' => $this->getConfiguration('association_type_id', false), 'current_product' => $this->getConfiguration('current_product', false)]; if (method_exists($this->qb, 'setParameters')) { QueryBuilderUtility::removeExtraParameters($this->qb); } $rows = $this->hydrator->hydrate($this->qb, $options); return $rows; }
/** * Retrieve entity ids, filters, sorters and limits are already in the datasource query builder * * @param DatasourceInterface $datasource * * @return array */ protected function getEntityIds(DatasourceInterface $datasource) { $getIdsQb = clone $datasource->getQueryBuilder(); $rootEntity = current($getIdsQb->getRootEntities()); $rootAlias = $getIdsQb->getRootAlias(); $rootField = $rootAlias . '.id'; $getIdsQb->add('from', new From($rootEntity, $rootAlias, $rootField), false); $getIdsQb->groupBy($rootField); QueryBuilderUtility::removeExtraParameters($getIdsQb); $results = $getIdsQb->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY); return array_keys($results); }
/** * {@inheritdoc} */ public function computeNbResult() { $qb = clone $this->getQueryBuilder(); $rootAlias = $qb->getRootAlias(); $rootField = $rootAlias . '.id'; $qb->groupBy($rootField); $qb->setFirstResult(null)->setMaxResults(null)->resetDQLPart('orderBy'); QueryBuilderUtility::removeExtraParameters($qb); $query = $qb->getQuery(); return QueryCountCalculator::calculateCount($query); }