groupUnique example


            [
                'orderId' => Uuid::fromHexToBytes($orderId),
                'documentTypeIds' => Uuid::fromHexToBytesList($documentTypeIds),
            ],
            [
                'documentTypeIds' => ArrayParameterType::STRING,
            ]
        );

        return array_column(FetchModeHelper::groupUnique($documents), 'doc_id');
    }

    /** * @param array<string> $documentIds * @param MailAttachments $attachments * * @return MailAttachments */
    private function mappingAttachments(array $documentIds, array $attachments, Context $context): array
    {
        foreach ($documentIds as $documentId) {
            
$query->setParameter(
            'ids',
            Uuid::fromHexToBytesList($ids),
            ArrayParameterType::STRING
        )->setParameter(
            'flowTypes',
            $this->conditionRegistry->getFlowRuleNames(),
            ArrayParameterType::STRING
        );

        return FetchModeHelper::groupUnique($query->executeQuery()->fetchAllAssociative());
    }

    private function addSelect(QueryBuilder $query, AssociationField $associationField): void
    {
        $template = 'EXISTS(%s) AS %s';
        $propertyName = $associationField->getPropertyName();

        if ($associationField instanceof OneToOneAssociationField || $associationField instanceof ManyToOneAssociationField) {
            $template = 'IF(%s.%s IS NOT NULL, 1, 0) AS %s';
            $query->addSelect(sprintf($template, '`rule`', $this->escape($associationField->getStorageName())$propertyName));

            
$result = $this->connection->fetchAllAssociative(' # navigation-route::meta-information SELECT LOWER(HEX(`id`)), `path`, `level` FROM `category` WHERE `id` = :activeId OR `parent_id` = :activeId OR `id` = :rootId ', ['activeId' => Uuid::fromHexToBytes($activeId), 'rootId' => Uuid::fromHexToBytes($rootId)]);

        if (!$result) {
            throw CategoryException::categoryNotFound($activeId);
        }

        return FetchModeHelper::groupUnique($result);
    }

    /** * @param array<string, CategoryMetaInformation> $metaInfo * * @return CategoryMetaInformation */
    private function getMetaInfoById(string $id, array $metaInfo): array
    {
        if (!\array_key_exists($id$metaInfo)) {
            throw CategoryException::categoryNotFound($id);
        }

                'ids' => $ids,
                'languageIds' => Uuid::fromHexToBytesList($context->getLanguageIdChain()),
                'liveVersionId' => Uuid::fromHexToBytes($context->getVersionId()),
            ],
            [
                'ids' => ArrayParameterType::STRING,
                'languageIds' => ArrayParameterType::STRING,
            ]
        );

        return FetchModeHelper::groupUnique($data);
    }

    /** * @return array<string, mixed> */
    private function getCustomFieldsMapping(Context $context): array
    {
        $fieldMapping = $this->getCustomFieldTypes($context);
        $mapping = [
            'type' => 'object',
            'dynamic' => true,
            
$query->from('sales_channel');
        $query->innerJoin('sales_channel', 'sales_channel_domain', 'domain', 'domain.sales_channel_id = sales_channel.id');
        $query->innerJoin('domain', 'snippet_set', 'snippet_set', 'snippet_set.id = domain.snippet_set_id');
        $query->leftJoin('sales_channel', 'theme_sales_channel', 'theme_sales_channel', 'sales_channel.id = theme_sales_channel.sales_channel_id');
        $query->leftJoin('theme_sales_channel', 'theme', 'theme', 'theme_sales_channel.theme_id = theme.id');
        $query->leftJoin('theme', 'theme', 'parentTheme', 'theme.parent_theme_id = parentTheme.id');
        $query->where('sales_channel.type_id = UNHEX(:typeId)');
        $query->andWhere('sales_channel.active');
        $query->setParameter('typeId', Defaults::SALES_CHANNEL_TYPE_STOREFRONT);

        /** @var array<string, Domain> $domains */
        $domains = FetchModeHelper::groupUnique($query->executeQuery()->fetchAllAssociative());

        return $domains;
    }
}
$query->andWhere('product.version_id = :version');

        $query->setParameter('version', Uuid::fromHexToBytes($context->getVersionId()));
        $query->setParameter('live', Uuid::fromHexToBytes(Defaults::LIVE_VERSION));

        $bytes = array_map(fn (string $id) => Uuid::fromHexToBytes($id)$ids);

        $query->setParameter('ids', $bytes, ArrayParameterType::STRING);

        $rows = $query->executeQuery()->fetchAllAssociative();

        return FetchModeHelper::groupUnique($rows);
    }

    /** * @param array<string, string|null> $mapping * * @return array<int, string> */
    private function mapCategories(array $mapping): array
    {
        $categoryIds = array_filter(explode('|', (string) $mapping['ids']));
        $categoryIds = array_merge(
            

    public function loadLanguages(): array
    {
        $data = $this->connection->createQueryBuilder()
            ->select(['LOWER(HEX(language.id)) AS array_key, LOWER(HEX(language.id)) AS id, locale.code, LOWER(HEX(language.parent_id)) parentId'])
            ->from('language')
            ->leftJoin('language', 'locale', 'locale', 'language.translation_code_id = locale.id')
            ->executeQuery()
            ->fetchAllAssociative();

        return FetchModeHelper::groupUnique($data);
    }
}

        $query = $this->connection->createQueryBuilder();
        $query->select('LOWER(HEX(product.id))', 'product.option_ids as options', 'product.product_number as productNumber', 'product.states as productStates');
        $query->from('product');
        $query->where('product.parent_id = :id');
        $query->andWhere('product.version_id = :versionId');
        $query->setParameter('id', Uuid::fromHexToBytes($productId));
        $query->setParameter('versionId', Uuid::fromHexToBytes($context->getVersionId()));
        $query->andWhere('product.option_ids IS NOT NULL');

        $combinations = $query->executeQuery()->fetchAllAssociative();
        $combinations = FetchModeHelper::groupUnique($combinations);

        foreach ($combinations as &$combination) {
            $combination['options'] = json_decode((string) $combination['options'], true, 512, \JSON_THROW_ON_ERROR);
        }

        return $combinations;
    }
}
public function getUrls(SalesChannelContext $context, int $limit, ?int $offset = null): UrlResult
    {
        $categories = $this->getCategories($context$limit$offset);

        if (empty($categories)) {
            return new UrlResult([], null);
        }
        $keys = FetchModeHelper::keyPair($categories);

        $seoUrls = $this->getSeoUrls(array_values($keys), 'frontend.navigation.page', $context$this->connection);

        $seoUrls = FetchModeHelper::groupUnique($seoUrls);

        $urls = [];
        $url = new Url();

        foreach ($categories as $category) {
            if (!isset($seoUrls[$category['id']])) {
                continue;
            }

            $lastMod = $category['updated_at'] ?: $category['created_at'];

            
$query->setParameter('salesChannelId', Uuid::fromHexToBytes($salesChannelId));

        $query->select([
            'LOWER(HEX(product.id))',
            'product.option_ids as options',
            'product.product_number as productNumber',
            'product.available',
        ]);

        $combinations = $query->executeQuery()->fetchAllAssociative();

        return FetchModeHelper::groupUnique($combinations);
    }
}

            ),
            KernelLifecycleManager::getConnection()
        );

        $translations = KernelLifecycleManager::getConnection()
            ->fetchAllAssociative(
                'SELECT LOWER(HEX(language_id)) as array_key, category_translation.* FROM category_translation WHERE category_id = :id',
                ['id' => Uuid::fromHexToBytes($ids->get('category'))]
            );

        $translations = FetchModeHelper::groupUnique($translations);

        static::assertArrayHasKey(Defaults::LANGUAGE_SYSTEM, $translations);
        static::assertArrayHasKey($ids->get('german')$translations);
        static::assertArrayHasKey($ids->get('en-2')$translations);

        static::assertEquals('en name', $translations[Defaults::LANGUAGE_SYSTEM]['name']);
        static::assertEquals('en name', $translations[$ids->get('en-2')]['name']);
        static::assertEquals('de name', $translations[$ids->get('german')]['name']);
    }

    private function createLanguages(IdsCollection $ids): void
    {

        $products = $this->getProducts($context$limit$offset);

        if (empty($products)) {
            return new UrlResult([], null);
        }

        $keys = FetchModeHelper::keyPair($products);

        $seoUrls = $this->getSeoUrls(array_values($keys), 'frontend.detail.page', $context$this->connection);

        $seoUrls = FetchModeHelper::groupUnique($seoUrls);

        $urls = [];
        $url = new Url();

        foreach ($products as $product) {
            $lastMod = $product['updated_at'] ?: $product['created_at'];

            $lastMod = (new \DateTime($lastMod))->format(Defaults::STORAGE_DATE_TIME_FORMAT);

            $newUrl = clone $url;

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