BooleanFacetResult example

$facet = $criteria->getFacet('immediate_delivery');
        if ($facet instanceof ImmediateDeliveryFacet && !empty($facet->getLabel())) {
            $label = $facet->getLabel();
        } else {
            $label = $this->snippetManager
                ->getNamespace('frontend/listing/facet_labels')
                ->get('immediate_delivery', 'Immediate delivery');
        }

        $fieldName = $this->queryAliasMapper->getShortAlias('immediateDelivery') ?? 'immediateDelivery';

        return new BooleanFacetResult(
            'immediate_delivery',
            $fieldName,
            $criteria->hasCondition('immediate_delivery'),
            $label
        );
    }
}


        $query = $this->queryBuilderFactory->createQuery($own$context);
        $query->select('1');
        $query->setMaxResults(1);

        $hasFacet = $query->execute()->fetch(PDO::FETCH_COLUMN);
        if (!$hasFacet) {
            return null;
        }

        return new BooleanFacetResult(
            $facet->getName(),
            $facet->getRequestParameter(),
            $criteria->hasCondition($facet->getName()),
            $facet->getLabel()
        );
    }
}
$fieldName = $this->queryAliasMapper->getShortAlias('shippingFree') ?? 'shippingFree';

        $facet = $criteria->getFacet('shipping_free');
        if ($facet instanceof ShippingFreeFacet && !empty($facet->getLabel())) {
            $label = $facet->getLabel();
        } else {
            $label = $this->snippetManager
                ->getNamespace('frontend/listing/facet_labels')
                ->get('shipping_free', 'Shipping free');
        }

        return new BooleanFacetResult(
            'shipping_free',
            $fieldName,
            $criteria->hasCondition('shipping_free'),
            $label
        );
    }
}
if ($total <= 0) {
            return null;
        }

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

        return new BooleanFacetResult(
            $facet->getName(),
            $this->fieldName,
            $criteria->hasCondition($facet->getName()),
            $label
        );
    }
}
if (!$criteria->hasFacet($key)) {
                continue;
            }

            $facet = $criteria->getFacet($key);
            if (!$facet instanceof CombinedConditionFacet) {
                continue;
            }

            $result->addFacet(
                new BooleanFacetResult(
                    $facet->getName(),
                    $facet->getRequestParameter(),
                    $criteria->hasCondition($facet->getName()),
                    $facet->getLabel()
                )
            );
        }
    }

    private function addQuery(
        CombinedConditionFacet $criteriaPart,
        

    private function createBooleanResult(ProductAttributeFacet $criteriaPart, array $data, Criteria $criteria): ?BooleanFacetResult
    {
        $count = $data[$criteriaPart->getName() . '_count'];
        $count = $count['value'];

        if ($count <= 0) {
            return null;
        }

        return new BooleanFacetResult(
            $criteriaPart->getName(),
            $criteriaPart->getFormFieldName(),
            $criteria->hasCondition($criteriaPart->getName()),
            $criteriaPart->getLabel()
        );
    }

    /** * @param array<string, mixed> $data */
    private function createRangeResult(ProductAttributeFacet $criteriaPart, array $data, Criteria $criteria): RangeFacetResult
    {
 ?BooleanFacetResult {
        $sqlField = 'productAttribute.' . $facet->getField();

        $query->select('COUNT(' . $sqlField . ')');

        $result = $query->execute()->fetch(PDO::FETCH_COLUMN);

        if (empty($result)) {
            return null;
        }

        return new BooleanFacetResult(
            $facet->getName(),
            $facet->getFormFieldName(),
            $criteria->hasCondition($facet->getName()),
            $facet->getLabel()
        );
    }

    private function addTranslations(QueryBuilder $query, ShopContextInterface $context): void
    {
        if ($context->getShop()->isDefault()) {
            return;
        }
if ($total <= 0) {
            return null;
        }

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

        return new BooleanFacetResult(
            $facet->getName(),
            $this->fieldName,
            $criteria->hasCondition($facet->getName()),
            $label
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.