getAverage example

CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $search->addPostFilter($this->getQuery($criteriaPart));
    }

    private function getQuery(VoteAverageCondition $criteriaPart): RangeQuery
    {
        return new RangeQuery('voteAverage.average', [
            'gte' => $criteriaPart->getAverage() * 2,
        ]);
    }
}


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

        if (!$data) {
            return null;
        }

        $activeAverage = null;
        $condition = $criteria->getCondition($facet->getName());
        if ($condition instanceof VoteAverageCondition) {
            $activeAverage = $condition->getAverage();
        }

        $values = $this->buildItems($data$activeAverage);

        if (!empty($facet->getLabel())) {
            $label = $facet->getLabel();
        } else {
            $label = $this->snippetNamespace->get($facet->getName(), 'Shipping free');
        }

        return new RadioFacetResult(
            
 . $shopCondition . ' GROUP BY vote.articleID';

        $query->innerJoin(
            'product',
            '(' . $table . ')',
            'voteAverage',
            'voteAverage.product_id = product.id AND voteAverage.average >= :average'
        );

        $query->setParameter(':average', (float) $condition->getAverage());
        $query->addState(VoteAverageCondition::STATE_INCLUDES_VOTE_TABLE);
    }
}
return $this->eventManager->filter('Legacy_Struct_Converter_Convert_Product', $data[
            'product' => $product,
        ]);
    }

    /** * @return array */
    public function convertVoteAverageStruct(VoteAverage $average)
    {
        $data = [
            'average' => round($average->getAverage(), 1),
            'count' => $average->getCount(),
            'pointCount' => $average->getPointCount(),
            'attributes' => $average->getAttributes(),
        ];

        if ($average->hasAttribute('core')) {
            $data['attribute'] = $average->getAttribute('core');
        }

        return $this->eventManager->filter('Legacy_Struct_Converter_Convert_Vote_Average', $data[
            'average' => $average,
        ]);
$result->addFacet($criteriaPart);
    }

    /** * @param array<string, mixed> $buckets */
    private function createFacet(Criteria $criteria, array $buckets): RadioFacetResult
    {
        $activeAverage = null;
        $condition = $criteria->getCondition('vote_average');
        if ($condition instanceof VoteAverageCondition) {
            $activeAverage = $condition->getAverage();
        }

        $values = $this->buildItems($buckets$activeAverage);

        $facet = $criteria->getFacet('vote_average');
        if ($facet instanceof VoteAverageFacet && !empty($facet->getLabel())) {
            $label = $facet->getLabel();
        } else {
            $label = $this->snippetManager
                ->getNamespace('frontend/listing/facet_labels')
                ->get('vote_average', 'Ranking');
        }
Home | Imprint | This part of the site doesn't use cookies.