getFacetName example

private function sortFacets(Criteria $criteria, ProductNumberSearchResult $result): array
    {
        $sorting = array_map(function DFacetInterface $facet) {
            return $facet->getName();
        }$criteria->getFacets());

        $sorting = array_flip(array_values($sorting));

        $sortedFacets = [];

        foreach ($result->getFacets() as $facetResult) {
            if (\array_key_exists($facetResult->getFacetName()$sorting)) {
                $position = $sorting[$facetResult->getFacetName()];
            } else {
                $position = \count($sorting) + \count($sortedFacets) + 1;
            }

            $sortedFacets[$position] = $facetResult;
        }

        ksort($sortedFacets, SORT_NUMERIC);

        return $sortedFacets;
    }
$manufacturer = $this->manufacturerService->get(
            $manufacturerId,
            $context
        );

        if ($manufacturer === null) {
            throw new Enlight_Controller_Exception('Manufacturer missing, non-existent or invalid', 404);
        }

        $facets = [];
        foreach ($categoryProducts['facets'] as $facet) {
            if (!$facet instanceof FacetResultInterface || $facet->getFacetName() === 'manufacturer') {
                continue;
            }
            $facets[] = $facet;
        }

        $categoryProducts['facets'] = $facets;

        $this->View()->assign($categoryProducts);
        $this->View()->assign('showListing', true);
        $this->View()->assign('manufacturer', $manufacturer);
        $this->View()->assign('ajaxCountUrlParams', [
            


    /** * @param FacetResultInterface[] $facets * @param string $name * * @return FacetResultInterface|null */
    private function getFacetByName(array $facets$name)
    {
        foreach ($facets as $facet) {
            if ($facet->getFacetName() === $name) {
                return $facet;
            }
        }

        return null;
    }

    /** * @param FacetResultInterface[] $facets */
    private function switchActivePriceFilter(array $facets, Criteria $criteria)
    {
Home | Imprint | This part of the site doesn't use cookies.