createCriteria example

$slotConfig = $salesChannel->getTranslation('homeSlotConfig');
        }

        if (!$pageId) {
            return new CategoryRouteResponse($category);
        }

        $resolverContext = new EntityResolverContext($context$request$this->categoryDefinition, $category);

        $pages = $this->cmsPageLoader->load(
            $request,
            $this->createCriteria($pageId$request),
            $context,
            $slotConfig,
            $resolverContext
        );

        if (!$pages->has($pageId)) {
            throw CategoryException::pageNotFound($pageId);
        }

        /** @var CmsPageEntity $page */
        $page = $pages->get($pageId);
        
$page->setDeepLinkCode($request->get('deepLinkCode'));

        $this->eventDispatcher->dispatch(
            new AccountEditOrderPageLoadedEvent($page$salesChannelContext$request)
        );

        return $page;
    }

    private function getOrder(Request $request, SalesChannelContext $context): OrderRouteResponse
    {
        $criteria = $this->createCriteria($request$context);
        $apiRequest = new Request();
        $apiRequest->query->set('checkPromotion', 'true');

        $event = new OrderRouteRequestEvent($request$apiRequest$context$criteria);
        $this->eventDispatcher->dispatch($event);

        return $this->orderRoute
            ->load($event->getStoreApiRequest()$context$criteria);
    }

    private function createCriteria(Request $request, SalesChannelContext $context): Criteria
    {

    protected function getList($filter$sort$offset$limit)
    {
        $sort = $this->resolveSortParameter($sort);

        if ($this->container->getParameter('shopware.es.backend.enabled')) {
            $repository = $this->container->get(AttributeOrderRepository::class);
            $criteria = $this->createCriteria();
            $result = $repository->search($criteria);

            $total = $result->getCount();
            $ids = array_column($result->getData(), 'id');
        } else {
            $searchResult = $this->getRepository()->search($offset$limit$filter$sort);
            $total = $searchResult['total'];
            $ids = array_column($searchResult['orders'], 'id');
        }

        $orders = $this->getRepository()->getList($ids);
        


    /** * @throws CustomerNotLoggedInException * @throws GuestNotAuthenticatedException * @throws WrongGuestCredentialsException * * @return EntitySearchResult<OrderCollection> */
    private function getOrders(Request $request, SalesChannelContext $context): EntitySearchResult
    {
        $criteria = $this->createCriteria($request);
        $apiRequest = new Request();

        // Add email and zipcode for guest customer verification in order view         if ($request->get('email', false) && $request->get('zipcode', false)) {
            $apiRequest->query->set('email', $request->get('email'));
            $apiRequest->query->set('zipcode', $request->get('zipcode'));
        }

        $event = new OrderRouteRequestEvent($request$apiRequest$context$criteria);
        $this->eventDispatcher->dispatch($event);

        
 Criteria {
        $streamId = $this->getStreamIdOfCategory($categoryId);
        if ($streamId === null) {
            return $this->storeFrontCriteriaFactory->createProductNavigationCriteria(
                $request,
                $context,
                $categoryId
            );
        }

        $factory = Shopware()->Container()->get(CriteriaFactoryInterface::class);
        $criteria = $factory->createCriteria($request$context);
        $criteria->limit(null);

        $streamRepository = Shopware()->Container()->get(Repository::class);
        $streamRepository->prepareCriteria($criteria$streamId);

        return $criteria;
    }

    private function getStreamIdOfCategory(int $categoryId): ?int
    {
        $streamId = $this->db->fetchOne('SELECT `stream_id` FROM `s_categories` WHERE id = ?', [$categoryId]);

        


use Enlight_Controller_Request_Request as Request;
use Shopware\Bundle\AttributeBundle\Repository\RegistryInterface;
use Shopware\Bundle\AttributeBundle\Repository\SearchCriteria;

class Shopware_Controllers_Backend_EntitySearch extends Shopware_Controllers_Backend_ExtJs
{
    public function searchAction()
    {
        try {
            $criteria = $this->createCriteria($this->Request());

            /** @var RegistryInterface $registry */
            $registry = $this->get('shopware_attribute.repository_registry');

            $repository = $registry->getRepository($criteria);
            $result = $repository->search($criteria);

            $this->View()->assign([
                'success' => true,
                'data' => array_values($result->getData()),
                'total' => $result->getCount(),
            ]);
/** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $this->io = new ShopwareStyle($input$output);
        $context = Context::createDefaultContext();

        $this->initializeCommand($input$context);

        /** @var RepositoryIterator<MediaCollection> $mediaIterator */
        $mediaIterator = new RepositoryIterator($this->mediaRepository, $context$this->createCriteria());

        if (!$this->isAsync) {
            $this->generateSynchronous($mediaIterator$context);
        } else {
            $this->generateAsynchronous($mediaIterator$context);
        }

        return self::SUCCESS;
    }

    private function initializeCommand(InputInterface $input, Context $context): void
    {
$this->criteriaFactory = $criteriaFactory;
        $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)'
            );

            
$result = $this->updateFrozenState($stream->getId()$stream->getFreezeUp()$stream->getConditions());
        if ($result) {
            $stream->setStatic($result['static']);
            $stream->setFreezeUp($result['freezeUp']);
        }

        if ($stream->getFreezeUp() !== null || $stream->isStatic()) {
            return;
        }

        $criteria = $this->criteriaFactory->createCriteria($stream->getId());

        $criteria->setFetchCount(false);
        $criteria->offset((int) $offset);

        if ($limit !== null) {
            $criteria->limit((int) $limit);
        }

        if ($criteria->getOffset() === 0) {
            $this->streamIndexer->clearStreamIndex($stream->getId());
        }

        
$default = array_shift($sortings);

        if (!$default) {
            return;
        }

        $this->Request()->setParam('sSort', $default->getId());
    }

    private function createCategoryStreamCriteria(int $categoryId, int $streamId, ShopContextInterface $context): Criteria
    {
        $criteria = $this->criteriaFactory->createCriteria($this->Request()$context);

        $this->productStreamRepository->prepareCriteria($criteria$streamId);

        $facets = $this->customFacetService->getFacetsOfCategories([$categoryId]$context);

        $facets = array_shift($facets);

        if (!\is_array($facets)) {
            $facets = [];
        }

        
 {
    }

    /** * @throws CategoryNotFoundException * @throws CustomerNotLoggedInException * @throws InconsistentCriteriaIdsException * @throws RoutingException */
    public function load(Request $request, SalesChannelContext $context, CustomerEntity $customer): WishlistPage
    {
        $criteria = $this->createCriteria($request);
        $this->eventDispatcher->dispatch(new WishListPageProductCriteriaEvent($criteria$context$request));

        $page = $this->genericLoader->load($request$context);
        $page = WishlistPage::createFrom($page);

        try {
            $page->setWishlist($this->wishlistLoadRoute->load($request$context$criteria$customer));
        } catch (CustomerWishlistNotFoundException) {
            $page->setWishlist(
                new LoadWishlistRouteResponse(
                    new CustomerWishlistEntity(),
                    


    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $salesChannelId = $input->getOption('salesChannelId');

        $context = Context::createDefaultContext();

        $criteria = $this->createCriteria($salesChannelId);

        $this->eventDispatcher->dispatch(
            new SitemapSalesChannelCriteriaEvent($criteria$context)
        );

        $salesChannels = $this->salesChannelRepository->search($criteria$context);

        /** @var SalesChannelEntity $salesChannel */
        foreach ($salesChannels as $salesChannel) {
            /** @var list<string> $languageIds */
            $languageIds = $salesChannel->getDomains()->map(fn (SalesChannelDomainEntity $salesChannelDomain) => $salesChannelDomain->getLanguageId());

            
ContextService::FALLBACK_CUSTOMER_GROUP
        );

        return $service->buildAdditionalTextLists($products$context);
    }

    /** * @return array{data: array, total: int} */
    private function filterByRepository(): array
    {
        $criteria = $this->createCriteria($this->Request());

        if ($this->Request()->getParam('showVariants', 'false') === 'false') {
            $criteria->conditions[] = [
                'property' => 'kind',
                'value' => 1,
            ];
        }

        $repository = $this->container->get(ProductRepository::class);

        $result = $repository->search($criteria);

        

    public function load(Request $request, SalesChannelContext $context): ReviewLoaderResult
    {
        $productId = $request->get('parentId') ?? $request->get('productId');
        if (!$productId) {
            throw RoutingException::missingRequestParameter('productId');
        }

        $criteria = $this->createCriteria($request$context);

        $reviews = $this->route
            ->load($productId$request$context$criteria)
            ->getResult();

        $reviews = StorefrontSearchResult::createFrom($reviews);

        $this->eventDispatcher->dispatch(new ProductReviewsLoadedEvent($reviews$context$request));

        $reviewResult = ReviewLoaderResult::createFrom($reviews);
        $reviewResult->setProductId($request->get('productId'));
        
$pageId = $landingPage->getCmsPageId();

        if (!$pageId) {
            return new LandingPageRouteResponse($landingPage);
        }

        $resolverContext = new EntityResolverContext($context$request$this->landingPageDefinition, $landingPage);

        $pages = $this->cmsPageLoader->load(
            $request,
            $this->createCriteria($pageId$request),
            $context,
            $landingPage->getTranslation('slotConfig'),
            $resolverContext
        );

        if (!$pages->has($pageId)) {
            throw new PageNotFoundException($pageId);
        }

        $landingPage->setCmsPage($pages->get($pageId));

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