getOptimizedCriteriaListPosition example

/** * @param array<string, Criteria> $criteriaList * * @return array<array{criteria: Criteria, requests: array<array{criteria: Criteria, key: string}>}> */
    private function getOptimizedCriteriaList(array $criteriaList): array
    {
        $optimizedCriteriaList = [];

        foreach ($criteriaList as $key => $originalCriteria) {
            $criteriaPosition = $this->getOptimizedCriteriaListPosition($originalCriteria$optimizedCriteriaList);

            if ($criteriaPosition !== false) {
                if (!isset($optimizedCriteriaList[$criteriaPosition]['criteria'])) {
                    continue;
                }
                $existingCriteria = $optimizedCriteriaList[$criteriaPosition]['criteria'];

                // search requests already exists, increase limit to select more products and satisfy all requests                 $existingCriteria->limit($existingCriteria->getLimit() + $originalCriteria->getLimit());

                $optimizedCriteriaList[$criteriaPosition]['requests'][] = ['criteria' => $originalCriteria, 'key' => $key];
                
Home | Imprint | This part of the site doesn't use cookies.