getVariantFacet example

public function __construct(Connection $connection, VariantHelperInterface $variantHelper)
    {
        $this->connection = $connection;
        $this->variantHelper = $variantHelper;
    }

    /** * {@inheritdoc} */
    public function createCategoryQuery($categoryId$limit = null)
    {
        if (!$this->variantHelper->getVariantFacet()) {
            $query = $this->connection->createQueryBuilder()
                ->select(['categories.articleID', 'categories.articleID'])
                ->from('s_articles_categories_ro', 'categories')
                ->andWhere('categories.articleID > :lastId')
                ->andWhere('categories.categoryID = :categoryId')
                ->setParameter(':categoryId', $categoryId, PDO::PARAM_INT)
                ->setParameter(':lastId', 0, PDO::PARAM_INT)
                ->orderBy('categories.articleID');

            if ($limit !== null) {
                $query->setMaxResults($limit);
            }
$listingPrices = null;
        $combinations = null;
        $configurations = null;
        $variantConfiguration = null;
        $products = $this->productGateway->getList($numbers$context);
        $average = $this->voteService->getAverages($products$context);
        $cheapest = $this->getCheapestPrices($products$shop->getId());
        $calculated = $this->getCalculatedPrices($shop$products$cheapest);
        $categories = $this->getCategories($products);
        $properties = $this->getProperties($products$context);

        $variantFacet = $this->variantHelper->getVariantFacet();

        $productIds = array_map(
            static function DListProduct $product) {
                return $product->getId();
            },
            $products
        );

        if ($variantFacet) {
            $variantConfiguration = $this->configuratorService->getProductsConfigurations($products$context);

            

    public function getType()
    {
        return self::TYPE;
    }

    /** * {@inheritdoc} */
    public function get(Shop $shop)
    {
        $variantFacet = $this->variantHelper->getVariantFacet();

        $productMapping = [
            'dynamic' => $this->isDynamic,
            'dynamic_templates' => [
                [
                    'variants_float_prices_to_double' => [
                        'path_match' => 'listingVariationPrices.*',
                        'match_mapping_type' => 'double',
                        'mapping' => [
                            'type' => 'double',
                        ],
                    ],
$this->queryFactory = $queryFactory;
        $this->variantHelper = $variantHelper;
    }

    public function populate(ShopIndex $index, ProgressHelperInterface $progress)
    {
        $categoryId = $index->getShop()->getCategory()->getId();
        $idQuery = $this->queryFactory->createCategoryQuery($categoryId, 100);
        $progress->start($idQuery->fetchCount(), 'Indexing products');

        while ($ids = $idQuery->fetch()) {
            if (!$this->variantHelper->getVariantFacet()) {
                $query = $this->queryFactory->createProductIdQuery($ids);
                $numbers = $query->fetch();
            } else {
                $numbers = $ids;
            }

            $this->indexProducts($index$numbers);
            $progress->advance(\count(array_unique($ids)));
        }
        $progress->finish();
    }

    
if (empty($filters)) {
            return;
        }

        $filters = explode('|', $filters);
        $filters = $this->getGroupedFilters($filters);

        if (empty($filters)) {
            return;
        }

        $facet = $this->variantHelper->getVariantFacet();
        $groups = [];
        if ($facet) {
            $groups = $facet->getExpandGroupIds();
        }

        foreach ($filters as $groupId => $filter) {
            $condition = new VariantCondition($filter, \in_array($groupId$groups)$groupId);
            $criteria->addCondition($condition);
        }
    }

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