private function generateCriteria(Element
$element, ShopContextInterface
$context): Criteria
{ $type =
$element->
getConfig()->
get(self::SLIDER_TYPE_KEY
);
$limit =
(int) $element->
getConfig()->
get('article_slider_max_number'
);
$categoryId =
(int) $element->
getConfig()->
get('article_slider_category'
);
if ($type === self::TYPE_PRODUCT_STREAM
) { $categoryId =
$context->
getShop()->
getCategory()->
getId();
} $criteria =
$this->criteriaFactory->
createBaseCriteria([$categoryId],
$context);
$criteria->
limit($limit);
switch ($type) { case self::TYPE_LOWEST_PRICE:
$criteria->
addSorting(new PriceSorting(SortingInterface::SORT_ASC
));
break;
case self::TYPE_HIGHEST_PRICE:
$criteria->
addSorting(new PriceSorting(SortingInterface::SORT_DESC
));
break;
case self::TYPE_TOPSELLER:
$criteria->
addSorting(new PopularitySorting(SortingInterface::SORT_DESC
));