getTotal example

return $shopId;
    }

    private function getInstalledApp(Context $context): AppEntity
    {
        /** @var EntityRepository $appRepo */
        $appRepo = $this->getContainer()->get('app.repository');

        $criteria = new Criteria();
        $criteria->addAssociation('integration');
        $apps = $appRepo->search($criteria$context);
        static::assertEquals(1, $apps->getTotal());

        return $apps->first();
    }
}

        $salesChannelContext = $this->contextFactory->create(Uuid::randomHex()$this->salesChannelId1);

        $request = new Request();
        $request->attributes->set('_route_params', ['navigationId' => $this->categoryId]);

        $data = $this->getContainer()
            ->get(ProductListingRoute::class)
            ->load($this->categoryId, $request$salesChannelContextnew Criteria())
            ->getResult();

        static::assertSame(1, $data->getTotal());
        static::assertTrue($data->has($this->productId3));

        $salesChannelContext = $this->contextFactory->create(Uuid::randomHex()$this->salesChannelId2);

        $data = $this->getContainer()
            ->get(ProductListingRoute::class)
            ->load($this->categoryId, $request$salesChannelContextnew Criteria())
            ->getResult();

        static::assertSame(1, $data->getTotal());
        static::assertTrue($data->has($this->productId1));
    }

        return $this->price->getPositionPrice();
    }

    /** * Alias for `getTotal()`. * * @return float The rounded total price of the cart as float. */
    public function getRounded(): float
    {
        return $this->getTotal();
    }

    /** * `getRaw() returns the total price of the cart before rounding. * * @return float The total price before rounding as float. */
    public function getRaw(): float
    {
        return $this->price->getRawTotal();
    }
}


        $response = $this->getBrowser()->getResponse();

        static::assertNotEquals(403, $response->getStatusCode()$response->getContent());
    }

    public function testItDoesNotValidateCascadeDeletes(): void
    {
        /** @var EntityRepository $salesChannelRepository */
        $salesChannelRepository = $this->getContainer()->get('sales_channel.repository');
        $countBefore = $salesChannelRepository->search(new Criteria(), Context::createDefaultContext())->getTotal();

        // system_config has a cascade delete on sales_channel         $this->getBrowser()
            ->request(
                'DELETE',
                '/api/sales-channel/' . TestDefaults::SALES_CHANNEL
            );

        $response = $this->getBrowser()->getResponse();

        static::assertEquals(204, $response->getStatusCode()$response->getContent());

        
static::assertEquals(
            'Updated maintenance mode for 1 sales channel(s)',
            $commandTester->getDisplay()
        );
    }

    public function testAllSalesChannelIds(): void
    {
        /** @var EntityRepository $salesChannelRepository */
        $salesChannelRepository = $this->getContainer()->get('sales_channel.repository');
        $count = $salesChannelRepository->search(new Criteria(), Context::createDefaultContext())->getTotal();

        $commandTester = new CommandTester($this->getContainer()->get(SalesChannelMaintenanceEnableCommand::class));
        $commandTester->execute(['--all' => true]);

        static::assertEquals(
            sprintf('Updated maintenance mode for %d sales channel(s)', $count),
            $commandTester->getDisplay()
        );
    }
}
'first' => $this->buildPaginationUrl($uri$parameters$limit, 1),
        ];

        $currentPage = 1 + (int) floor($offset / $limit);
        if ($currentPage > 1) {
            $pagination['prev'] = $this->buildPaginationUrl($uri$parameters$limit$currentPage - 1);
        }

        $totalCountMode = $searchResult->getCriteria()->getTotalCountMode();
        switch ($totalCountMode) {
            case Criteria::TOTAL_COUNT_MODE_NONE:
                if ($searchResult->getTotal() >= $limit) {
                    $pagination['next'] = $this->buildPaginationUrl($uri$parameters$limit$currentPage + 1);
                }

                break;

            case Criteria::TOTAL_COUNT_MODE_EXACT:
                $lastPage = (int) ceil($searchResult->getTotal() / $limit);
                $lastPage = $lastPage >= 1 ? $lastPage : 1;
                $pagination['last'] = $this->buildPaginationUrl($uri$parameters$limit$lastPage);

                if ($currentPage < $lastPage) {
                    
$criteria->setLimit($this->exportLimit <= 0 ? 250 : $this->exportLimit);
        $fullExport = $this->exportLimit <= 0;

        /** @var ImportExportFileEntity $file */
        $file = $this->logEntity->getFile();
        $targetFile = $this->getPartFilePath($file->getPath()$offset);

        do {
            $result = $this->repository->search($criteria$context);
            if ($this->total === null) {
                $this->total = $result->getTotal();
                $criteria->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_NONE);
            }

            $entities = $result->getEntities();
            if (\count($entities) === 0) {
                // this can happen if entities are deleted while we export                 $progress->setTotal($progress->getOffset());

                break;
            }

            
$this->finalizeExport($productExport$filePath);

            return;
        }

        $this->productExportFileHandler->writeProductExportContent(
            $exportResult->getContent(),
            $filePath,
            $productExportPartialGeneration->getOffset() > 0
        );

        if ($productExportPartialGeneration->getOffset() + $this->readBufferSize < $exportResult->getTotal()) {
            $this->messageBus->dispatch(
                new ProductExportPartialGeneration(
                    $productExportPartialGeneration->getProductExportId(),
                    $productExportPartialGeneration->getSalesChannelId(),
                    $productExportPartialGeneration->getOffset() + $this->readBufferSize
                )
            );

            return;
        }

        
$this->criteria = $criteria;
    }

    public function getTotal(): int
    {
        $criteria = clone $this->criteria;
        $criteria->setOffset(0);
        $criteria->setLimit(1);
        $criteria->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_EXACT);

        return $this->repository->searchIds($criteria$this->context)->getTotal();
    }

    /** * @return list<string>|list<array<string, string>>|null */
    public function fetchIds(): ?array
    {
        $this->criteria->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_NONE);
        $ids = $this->repository->searchIds($this->criteria, $this->context);
        $this->criteria->setOffset($this->criteria->getOffset() + $this->criteria->getLimit());

        

    public function __construct(private readonly FilterTagIdsService $filterTagIdsService)
    {
    }

    #[Route(path: '/api/_admin/tag-filter-ids', name: 'api.admin.tag-filter-ids', defaults: ['_acl' => ['tag:read'], '_entity' => 'tag'], methods: ['POST'])]     public function filterIds(Request $request, Criteria $criteria, Context $context): JsonResponse
    {
        $filteredTagIdsStruct = $this->filterTagIdsService->filterIds($request$criteria$context);

        return new JsonResponse([
            'total' => $filteredTagIdsStruct->getTotal(),
            'ids' => $filteredTagIdsStruct->getIds(),
        ]);
    }
}
public function countNotUsedMedia(Context $context): int
    {
        Feature::triggerDeprecationOrThrow(
            'v6.6.0.0',
            sprintf('%s is deprecated and will be removed in v6.6.0.0. Use %s instead.', self::class, UnusedMediaPurger::class),
        );

        $criteria = $this->createFilterForNotUsedMedia($context);
        $criteria->setLimit(1);
        $criteria->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_EXACT);

        return $this->mediaRepo->search($criteria$context)->getTotal();
    }

    public function deleteNotUsedMedia(Context $context): void
    {
        Feature::triggerDeprecationOrThrow(
            'v6.6.0.0',
            sprintf('%s is deprecated and will be removed in v6.6.0.0. Use %s instead.', self::class, UnusedMediaPurger::class),
        );

        $criteria = $this->createFilterForNotUsedMedia($context);

        
99.99
        );

        $stubs = $this->createMock(ScriptPriceStubs::class);
        $price = new PriceCollection([]);

        $stubs->method('build')->willReturn($price);

        $facade = new CartPriceFacade($original$stubs);

        static::assertEquals(100, $facade->getNet());
        static::assertEquals(200, $facade->getTotal());
        static::assertEquals(200, $facade->getRounded());
        static::assertEquals(300, $facade->getPosition());
        static::assertEquals(99.99, $facade->getRaw());

        static::assertSame($price$facade->create([]));
    }
}
$customerRepository->create([$customer->build()]$context);

        static::assertEquals(1, $this->service->countUnusedCustomers($context));

        $this->service->deleteUnusedCustomers($context);

        static::assertEquals(0, $this->service->countUnusedCustomers($context));

        $result = $customerRepository->search(new Criteria([$this->ids->get('10000')])$context);

        static::assertEquals(0, $result->getTotal());
    }

    public function testItDoesOnlyDeleteGuestCustomers(): void
    {
        $context = Context::createDefaultContext();
        $customerRepository = $this->getContainer()->get('customer.repository');

        $customer = (new CustomerBuilder($this->ids, '10000'))
            ->add('guest', false)
            ->add('createdAt', new \DateTime('- 25 hours'));

        
$this->productExportRepository->update(
                [
                    [
                        'id' => $primaryKey,
                        'generatedAt' => null,
                    ],
                ],
                $event->getContext()
            );
            $productExportResult = $this->productExportRepository->search(new Criteria([$primaryKey])$event->getContext());
            if ($productExportResult->getTotal() !== 0) {
                $productExport = $productExportResult->first();

                $filePath = $this->productExportFileHandler->getFilePath($productExport);
                if ($this->fileSystem->fileExists($filePath)) {
                    $this->fileSystem->delete($filePath);
                }
            }
        }
    }

    private function productExportWritten(EntityWriteResult $writeResult): bool
    {
$this->repository = $repository;
        $this->context = clone $context;
    }

    public function getTotal(): int
    {
        $criteria = clone $this->criteria;
        $criteria->setOffset(0);
        $criteria->setLimit(1);
        $criteria->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_EXACT);

        return $this->repository->searchIds($criteria$this->context)->getTotal();
    }

    /** * @return list<string>|list<array<string, string>>|null */
    public function fetchIds(): ?array
    {
        $this->criteria->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_NONE);

        $ids = $this->repository->searchIds($this->criteria, $this->context);

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