hydrateGroups example

$query->addOrderBy('configuratorOption.name');
        $query->groupBy('configuratorOption.id');
        $query->andWhere('configuratorOption.id IN (:ids)');
        $query->setParameter('ids', $optionIds, Connection::PARAM_INT_ARRAY);

        $this->fieldHelper->addConfiguratorGroupTranslation($query$context);
        $this->fieldHelper->addConfiguratorOptionTranslation($query$context);
        $this->fieldHelper->addMediaTranslation($query$context);

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        return $this->hydrator->hydrateGroups($data);
    }
}
$query->addGroupBy('product.id');
        $query->addGroupBy('configuratorOption.id');

        $query->where('variant.articleId IN (:articleIds)');
        $query->setParameter(':articleIds', $articleIds, Connection::PARAM_STR_ARRAY);

        $data = $query->execute()->fetchAll(PDO::FETCH_GROUP);

        $result = [];
        foreach ($data as $productId => $rows) {
            $result[(int) $productId] = $this->hydrator->hydrateGroups($rows);
        }

        return $result;
    }
}

        $this->attributeHydrator = $attributeHydrator;
        $this->mediaHydrator = $mediaHydrator;
    }

    /** * @return Set */
    public function hydrate(array $data)
    {
        $set = $this->createSet($data[0] ?? []);
        $set->setGroups($this->hydrateGroups($data));

        return $set;
    }

    /** * @return Group[] */
    public function hydrateGroups(array $data)
    {
        $groups = [];

        
$ids = [];
        foreach ($products as $product) {
            $ids[] = $product->getVariantId();
        }
        $ids = array_unique($ids);

        $data = $this->getQuery($ids$context)->execute()->fetchAll(PDO::FETCH_GROUP);

        $result = [];
        foreach ($data as $key => $groups) {
            $result[$key] = $this->configuratorHydrator->hydrateGroups($groups);
        }

        return $result;
    }

    /** * @param int[] $ids */
    private function getQuery(array $ids, ShopContextInterface $context): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();

        
Home | Imprint | This part of the site doesn't use cookies.