getProductIds example


        $this->assignConditions($productStream$criteria);

        $sortings = $criteria->getSortings();
        if (empty($sortings)) {
            $this->assignSortings($productStream$criteria);
        }
    }

    private function prepareSelectionStream(array $productStream, Criteria $criteria): void
    {
        $productIds = $this->getProductIds((int) $productStream['id']);
        $criteria->addBaseCondition(new ProductIdCondition($productIds));

        $sortings = $criteria->getSortings();
        if (empty($sortings)) {
            $this->assignSortings($productStream$criteria);
        }
    }

    /** * @return int[] */
    
$this->addCondition($condition$query);
    }

    private function addCondition(ProductIdCondition $condition, QueryBuilder $query): void
    {
        $key = ':productIds' . md5(json_encode($condition, JSON_THROW_ON_ERROR));

        $query->andWhere('variant.articleId IN (' . $key . ')');

        $query->setParameter(
            $key,
            $condition->getProductIds(),
            Connection::PARAM_INT_ARRAY
        );
    }
}
$element = new CrossSellingElement();
        $element->setCrossSelling($crossSelling);
        $element->setProducts(new ProductCollection());
        $element->setTotal(0);

        if (!$crossSelling->getAssignedProducts()) {
            return $element;
        }

        $crossSelling->getAssignedProducts()->sortByPosition();

        $ids = array_values($crossSelling->getAssignedProducts()->getProductIds());

        $filter = new ProductAvailableFilter(
            $context->getSalesChannel()->getId(),
            ProductVisibilityDefinition::VISIBILITY_LINK
        );

        if (!\count($ids)) {
            return $element;
        }

        $criteria->setIds($ids);
        
return ProductReviewDefinition::class;
    }

    /** * @param array<mixed> $options */
    public function generate(int $numberOfItems, DemodataContext $context, array $options = []): void
    {
        $context->getConsole()->progressStart($numberOfItems);

        $customerIds = $this->getCustomerIds();
        $productIds = $this->getProductIds();
        $salesChannelIds = $this->connection->fetchFirstColumn('SELECT LOWER(HEX(id)) FROM sales_channel');
        $points = [1, 2, 3, 4, 5];

        $payload = [];

        $writeContext = WriteContext::createFromContext($context->getContext());

        $customerIdsWithReviews = [];

        for ($i = 0; $i < $numberOfItems; ++$i) {
            $customerId = $context->getFaker()->randomElement($customerIds);
            
public function handlePostFilter(
        CriteriaPartInterface $criteriaPart,
        Criteria $criteria,
        Search $search,
        ShopContextInterface $context
    ) {
        $search->addPostFilter($this->getQuery($criteriaPart));
    }

    private function getQuery(ProductIdCondition $criteriaPart): TermsQuery
    {
        return new TermsQuery('id', $criteriaPart->getProductIds());
    }
}
Home | Imprint | This part of the site doesn't use cookies.