setCriteria example

$type = $element->getConfig()->get(self::SLIDER_TYPE_KEY, self::TYPE_STATIC_PRODUCT);
        $key = ComponentHandlerInterface::CRITERIA_KEY . $element->getId();

        switch ($type) {
            case self::TYPE_PRODUCT_STREAM:
                $criteria = $this->generateCriteria($element$context);

                $productStreamId = $element->getConfig()->get('article_slider_stream');
                $this->productStreamRepository->prepareCriteria($criteria$productStreamId);

                // request multiple products by criteria                 $collection->getBatchRequest()->setCriteria($key$criteria);
                break;

            case self::TYPE_TOPSELLER:
            case self::TYPE_NEWCOMER:
            case self::TYPE_RANDOM:
            case self::TYPE_LOWEST_PRICE:
            case self::TYPE_HIGHEST_PRICE:
                $criteria = $this->generateCriteria($element$context);

                // request multiple products by criteria                 $collection->getBatchRequest()->setCriteria($key$criteria);
                


    private function prepareHandlers(Criteria $criteria): void
    {
        $handlers = array_merge(
            $this->conditionHandlers,
            $this->sortingHandlers
        );

        foreach ($handlers as $handler) {
            if ($handler instanceof CriteriaAwareInterface) {
                $handler->setCriteria($criteria);
            }
        }
    }
}


        if ($type === self::TYPE_STATIC_VARIANT) {
            $collection->getBatchRequest()->setProductNumbers($key[$element->getConfig()->get('variant')]);

            return;
        }

        $criteria = $this->generateCriteria($element$context);

        // request multiple products by criteria         $collection->getBatchRequest()->setCriteria($key$criteria);
    }

    /** * {@inheritdoc} */
    public function handle(ResolvedDataCollection $collection, Element $element, ShopContextInterface $context)
    {
        $key = ComponentHandlerInterface::CRITERIA_KEY . $element->getId();
        $type = $element->getConfig()->get('article_type');

        $product = current($collection->getBatchResult()->get($key));
        
$isBlog = (bool) $element->getConfig()->get('blog_category');
                $categoryId = (int) $element->getConfig()->get('category_selection');

                if ($isBlog) {
                    break;
                }

                $criteria = $this->criteriaFactory->createBaseCriteria([$categoryId]$context);
                $criteria->addSorting(new ReleaseDateSorting(SortingInterface::SORT_DESC));
                $criteria->limit(50);

                $collection->getBatchRequest()->setCriteria($key$criteria);
                break;
        }
    }

    public function handle(ResolvedDataCollection $collection, Element $element, ShopContextInterface $context)
    {
        $imageType = $element->getConfig()->get('image_type');
        $key = ComponentHandlerInterface::CRITERIA_KEY . $element->getId();

        switch ($imageType) {
            case self::TYPE_IMAGE:
                
Home | Imprint | This part of the site doesn't use cookies.