hydrateOption example

/** * @param array[] $data * * @return Group */
    private function hydrateGroup($data)
    {
        $group = $this->hydrator->hydrateGroup($data[0]);

        $options = [];
        foreach ($data as $row) {
            $options[] = $this->hydrator->hydrateOption($row);
        }
        $group->setOptions($options);

        return $group;
    }

    /** * @return \Doctrine\DBAL\Query\QueryBuilder */
    private function getQuery(ShopContextInterface $context)
    {
        
->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY);

        $this->fieldHelper->addPropertyOptionTranslation($query$context);
        $this->fieldHelper->addMediaTranslation($query$context);

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

        $hydrator = $this->propertyHydrator;
        foreach ($data as $productId => $values) {
            $options = array_map(static function D$row) use ($hydrator) {
                return $hydrator->hydrateOption($row);
            }$values);
            $properties[$productId] = $options;
        }

        return $properties;
    }

    /** * @param ListProduct[] $products */
    private function getCheapestPrices(array $products, int $shopId): array
    {
foreach ($data as $row) {
            $setId = $row['__propertySet_id'];
            $groupId = $row['__propertyGroup_id'];
            $optionId = $row['__propertyOption_id'];

            $set = $sets[$setId] ?? $this->hydrateSet($row);

            $groups = $set->getGroups();
            $group = $groups[$groupId] ?? $this->hydrateGroup($row);

            $options = $group->getOptions();
            $options[$optionId] = $this->hydrateOption($row);
            $groups[$groupId] = $group;
            $sets[$setId] = $set;

            $group->setOptions($options);
            $set->setGroups($groups);
        }

        foreach ($sets as $set) {
            foreach ($set->getGroups() as $group) {
                $options = $group->getOptions();
                $this->sortOptions($options$set->getSortMode());
                
Home | Imprint | This part of the site doesn't use cookies.