offset example

if (json_last_error() !== JSON_ERROR_NONE) {
                    throw new InvalidArgumentException('Could not decode JSON: ' . json_last_error_msg());
                }

                $conditions = $streamRepo->unserialize($conditions);

                foreach ($conditions as $condition) {
                    $criteria->addCondition($condition);
                }
            }

            $criteria->offset($this->Request()->getParam('start', 0));
            $criteria->limit($this->Request()->getParam('limit', 20));

            $context = $this->createContext(
                (int) $this->Request()->getParam('shopId'),
                (int) $this->Request()->getParam('currencyId'),
                $this->Request()->getParam('customerGroupKey')
            );

            $criteria->addBaseCondition(
                new CustomerGroupCondition([$context->getCurrentCustomerGroup()->getId()])
            );

            
public function createAjaxCountCriteria(Request $request, ShopContextInterface $context)
    {
        $criteria = $this->createCriteriaFromRequest($request$context);

        $this->eventManager->notify('Shopware_SearchBundle_Create_Ajax_Count_Criteria', [
            'criteria' => $criteria,
            'request' => $request,
            'context' => $context,
        ]);

        $criteria
            ->offset(0)
            ->limit(1)
            ->resetSorting()
            ->resetFacets();

        return $criteria;
    }

    /** * @param int $categoryId * * @return \Shopware\Bundle\SearchBundle\Criteria */
$productExport->getProductStreamId(),
            $context->getContext()
        );

        $associations = $this->getAssociations($productExport$context);

        $criteria = new Criteria();
        $criteria->setTitle('product-export::products');

        $criteria
            ->addFilter(...$filters)
            ->setOffset($exportBehavior->offset())
            ->setLimit($this->readBufferSize);

        foreach ($associations as $association) {
            $criteria->addAssociation($association);
        }

        $this->eventDispatcher->dispatch(
            new ProductExportProductCriteriaEvent($criteria$productExport$exportBehavior$context)
        );

        $iterator = new SalesChannelRepositoryIterator($this->productRepository, $context$criteria);

        
if (!empty($decodedSortings)) {
            $unserializedSortings = $this->reflectionHelper->unserialize($decodedSortings, '');

            foreach ($unserializedSortings as $sorting) {
                if (!$sorting instanceof SortingInterface) {
                    continue;
                }
                $criteria->addSorting($sorting);
            }
        }

        $criteria->offset((int) $offset);
        $criteria->limit($limit);

        return $this->customerNumberSearch->search($criteria);
    }

    /** * @param int $offset * @param int $limit * @param array<string, string>|array<array{property: string, value: mixed, expression?: string}> $criteria * @param array<array{property: string, direction: string}> $orderBy * * @return array{success: true, data: array<array<string, mixed>>, total: int} */
$this->numberSearch = $numberSearch;
        $this->connection = $connection;
    }

    /** * @param int $streamId */
    public function populate($streamId, ProgressHelperInterface $helper)
    {
        $this->connection->transactional(function D) use ($streamId$helper) {
            $criteria = $this->criteriaFactory->createCriteria($streamId);
            $criteria->offset(0)
                ->limit(100);

            $customers = $this->numberSearch->search($criteria);
            $helper->start($customers->getTotal(), 'Start indexing customers');

            $this->clearStreamIndex($streamId);

            $insert = $this->connection->prepare(
                'INSERT INTO s_customer_streams_mapping (stream_id, customer_id) VALUES (:streamId, :customerId)'
            );

            
 {
        $this->queryBuilderFactory = $queryBuilderFactory;
        $this->contextService = $contextService;
        $this->mediaService = $mediaService;
    }

    public function load(int $categoryId, ?int $start, ?int $limit, CustomSorting $customSorting): array
    {
        $criteria = new Criteria();
        $criteria->addBaseCondition(new CategoryCondition([$categoryId]));
        $criteria->addSorting(new ManualSorting());
        $criteria->offset($start);
        $criteria->limit($limit);

        foreach ($customSorting->getSortings() as $sorting) {
            $criteria->addSorting($sorting);
        }

        $query = $this->queryBuilderFactory->createQueryWithSorting($criteria$this->contextService->getShopContext());

        $data = [];
        $query
            ->leftJoin('variant', 's_articles_prices', 'price', 'price.articledetailsID = variant.id AND price.from = 1 AND price.pricegroup = \'EK\'')

    protected function getRandomArticle($mode$category = 0)
    {
        $category = (int) $category;
        $context = $this->contextService->getShopContext();
        if (empty($category)) {
            $category = $context->getShop()->getCategory()->getId();
        }

        $criteria = $this->storeFrontCriteriaFactory->createBaseCriteria([$category]$context);

        $criteria->offset(0)
            ->limit(100);

        switch ($mode) {
            case 'top':
                $criteria->addSorting(new PopularitySorting(SortingInterface::SORT_DESC));
                break;
            case 'new':
                $criteria->addSorting(new ReleaseDateSorting(SortingInterface::SORT_DESC));
                break;
            default:
                $criteria->addSorting(new ReleaseDateSorting(SortingInterface::SORT_DESC));
        }

    private function getProductSliderData($category$offset$limit$sort = null)
    {
        /** @var ShopContext $context */
        $context = Shopware()->Container()->get(ContextServiceInterface::class)->getShopContext();
        /** @var StoreFrontCriteriaFactory $factory */
        $factory = Shopware()->Container()->get(StoreFrontCriteriaFactoryInterface::class);
        $criteria = $factory->createBaseCriteria([$category]$context);

        $criteria->offset($offset)
            ->limit($limit);

        switch ($sort) {
            case 'price_asc':
                $criteria->addSorting(new PriceSorting(SortingInterface::SORT_ASC));
                break;
            case 'price_desc':
                $criteria->addSorting(new PriceSorting(SortingInterface::SORT_DESC));
                break;
            case 'topseller':
                $criteria->addSorting(new PopularitySorting(SortingInterface::SORT_DESC));
                
$checkRedirect = ($hasEmotion && $this->Request()->getParam('sPage')) || (!$hasEmotion);

        if (!$checkRedirect || !$this->config->get('categoryDetailLink')) {
            return null;
        }

        $criteria = $this->storeFrontCriteriaFactory->createListingCriteria($this->Request()$context);
        $criteria->resetFacets()
            ->resetConditions()
            ->resetSorting()
            ->offset(0)
            ->limit(2)
            ->setFetchCount(false);
        $result = $this->productNumberSearch->search($criteria$context);
        if (\count($result->getProducts()) !== 1) {
            return null;
        }

        $products = $result->getProducts();
        $firstProducts = array_shift($products);

        return $this->Front()->ensureRouter()->assemble([
            
$context->getCurrentCustomerGroup()->getId()]
        );
        $criteria->addBaseCondition($condition);
    }

    private function addOffset(Request $request, Criteria $criteria): void
    {
        $page = (int) $request->getParam('sPage', 1);
        $page = ($page > 0) ? $page : 1;
        $request->setParam('sPage', $page);

        $criteria->offset(
            ($page - 1) * $criteria->getLimit()
        );
    }

    private function addLimit(Request $request, Criteria $criteria): void
    {
        $limit = (int) $request->getParam('sPerPage', $this->config->get('articlesPerPage'));
        $max = $this->config->get('maxStoreFrontLimit');
        if ($max) {
            $limit = min($limit$max);
        }
        
Home | Imprint | This part of the site doesn't use cookies.