setIds example

$criteria = new Criteria();

        $productIds = $request->get('productIds', []);

        if (!\is_array($productIds)) {
            throw RoutingException::missingRequestParameter('productIds');
        }

        $productIds = array_filter($productIdsstatic fn ($productId) => Uuid::isValid($productId));

        $criteria->setLimit(self::LIMIT);
        $criteria->setIds($productIds);

        $criteria->addAssociation('manufacturer')
            ->addAssociation('options.group')
            ->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_EXACT);

        if ($this->systemConfigService->getBool(
            'core.listing.hideCloseoutProductsWhenOutOfStock',
            $context->getSalesChannelId()
        )) {
            $closeoutFilter = $this->productCloseoutFilterFactory->create($context);
            $criteria->addFilter($closeoutFilter);
        }
string $appVersion,
        string $entity,
        string $action,
        array $ids,
        ?string $appSecret,
        string $shopId,
        string $actionId
    ) {
        $this->setAction($action);
        $this->setAppVersion($appVersion);
        $this->setEntity($entity);
        $this->setIds($ids);
        $this->setShopUrl($shopUrl);
        $this->setTargetUrl($targetUrl);
        $this->setAppSecret($appSecret);
        $this->setShopId($shopId);
        $this->setActionId($actionId);
    }

    public function getTargetUrl(): string
    {
        return $this->targetUrl;
    }

    
static::assertSame(Response::HTTP_INTERNAL_SERVER_ERROR, $e->getStatusCode());
            static::assertSame(DataAbstractionLayerException::INVALID_CRITERIA_IDS, $e->getErrorCode());

            $wasThrown = true;
        }
        static::assertTrue($wasThrown);

        $criteria = new Criteria();
        $wasThrown = false;

        try {
            $criteria->setIds($ids);
        } catch (InvalidCriteriaIdsException $e) {
            static::assertSame(Response::HTTP_INTERNAL_SERVER_ERROR, $e->getStatusCode());
            static::assertSame(DataAbstractionLayerException::INVALID_CRITERIA_IDS, $e->getErrorCode());

            $wasThrown = true;
        }
        static::assertTrue($wasThrown);
    }

    /** * @return iterable<string, array<mixed>> */
$fieldCriteria->addFilter(new EqualsAnyFilter($propertyAccessor$ids));

        $mapping = $this->fetchPaginatedOneToManyMapping($definition$association$context$collection$fieldCriteria);

        $ids = [];
        foreach ($mapping as $associationIds) {
            foreach ($associationIds as $associationId) {
                $ids[] = $associationId;
            }
        }

        $fieldCriteria->setIds(\array_filter($ids));
        $fieldCriteria->resetSorting();
        $fieldCriteria->resetFilters();
        $fieldCriteria->resetPostFilters();

        $referenceClass = $association->getReferenceDefinition();
        /** @var EntityCollection<Entity> $collectionClass */
        $collectionClass = $referenceClass->getCollectionClass();

        $data = $this->_read(
            $fieldCriteria,
            $referenceClass,
            
'categories' => [
                    ['name' => 'X'],
                    ['name' => 'A'],
                ],
            ]),
        ];

        $this->getContainer()->get('product.repository')
            ->create($data, Context::createDefaultContext());

        $criteria = new Criteria();
        $criteria->setIds($ids->getList(['product-1', 'product-2']));
        $criteria->addSorting(new FieldSorting('categories.name', FieldSorting::ASCENDING));

        $result = $this->getContainer()->get('product.repository')
            ->searchIds($criteria, Context::createDefaultContext());

        static::assertEquals(
            [$ids->get('product-2')$ids->get('product-1')],
            $result->getIds()
        );
    }

    


    /** * Set the ID used in the value of this header. * * @param string|string[] $id * * @throws RfcComplianceException */
    public function setId(string|array $id): void
    {
        $this->setIds(\is_array($id) ? $id : [$id]);
    }

    /** * Get the ID used in the value of this Header. * * If multiple IDs are set only the first is returned. */
    public function getId(): ?string
    {
        return $this->ids[0] ?? null;
    }

    
        $messagesBefore = $bus->getDispatchedMessages();
        $this->getTaskHandler()->run();
        $messagesAfter = $bus->getDispatchedMessages();

        static::assertCount(\count($messagesBefore)$messagesAfter);
    }

    protected function createSecondStorefrontSalesChannel(): void
    {
        $salesChannelRepository = $this->getContainer()->get('sales_channel.repository');
        $criteria = (new Criteria())
            ->setIds([$this->getSalesChannelDomain()->getSalesChannelId()])
            ->addAssociation('languages');

        /** @var SalesChannelEntity $originalSalesChannel */
        $originalSalesChannel = $salesChannelRepository->search($criteria$this->context)->first();

        /** @var LanguageCollection $originalSalesChannelLanguages */
        $originalSalesChannelLanguages = $originalSalesChannel->getLanguages();
        $originalSalesChannelArray = $originalSalesChannelLanguages->jsonSerialize();
        $languages = array_map(static fn ($language) => ['id' => $language->getId()]$originalSalesChannelArray);

        $id = '000000009276457086da48d5b5628f3c';
        
$eventDidRun = null;
        $phpunit = $this;
        $listenerClosure = function DGuestWishListPageletProductCriteriaEvent $event) use (
            &$eventDidRun,
            $phpunit,
            $productId,
            $context
        ): void {
            $eventDidRun = true;
            $expectedCriteria = new Criteria();
            $expectedCriteria->setLimit(100);
            $expectedCriteria->setIds([$productId]);
            $expectedCriteria->addAssociation('manufacturer')
                ->addAssociation('options.group')
                ->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_EXACT);

            $filter = $this->productCloseoutFilterFactory->create($context);
            $expectedCriteria->addFilter($filter);

            $phpunit->assertEquals($expectedCriteria$event->getCriteria());
        };

        $this->addEventListener($this->eventDispatcher, GuestWishListPageletProductCriteriaEvent::class$listenerClosure);

        

            ],
        ];

        $manufacturerRepo = $this->getContainer()->get('product_manufacturer.repository');
        $context = Context::createDefaultContext();
        $manufacturerRepo->upsert([$manufacturer]$context);

        $manufacturerCriteria = new Criteria([$manufacturerId]);

        $manufacturerCriteria->getAssociation('products')
            ->setIds([$productId])
            ->addAssociation('categories');

        /** @var ProductManufacturerEntity $manufacturer */
        $manufacturer = $manufacturerRepo->search($manufacturerCriteria$context)->get($manufacturerId);
        $products = $manufacturer->getProducts();
        static::assertNotNull($products);

        static::assertEquals(1, $products->count());
        static::assertInstanceOf(ProductEntity::class$products->first());

        $categories = $products->first()->getCategories();
        


    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $this->io = new SymfonyStyle($input$output);

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('theme.salesChannels.typeId', Defaults::SALES_CHANNEL_TYPE_STOREFRONT));

        $id = $input->getArgument('theme-id');
        if ($id !== null) {
            $criteria->setIds([$id]);
        }

        $themes = $this->themeRepository->search($criteria$this->context);

        if ($themes->count() === 0) {
            $this->io->error('No theme found which is connected to a storefront sales channel');

            return self::FAILURE;
        }

        /** @var ThemeEntity $themeEntity */
        
$context = Context::createDefaultContext();
        $criteria = new Criteria();

        if (!$input->getOption('all')) {
            $ids = $input->getArgument('ids');
            if ($ids === []) {
                $output->write('No sales channels were updated. Provide id(s) or run with --all option.');

                return self::SUCCESS;
            }

            $criteria->setIds($ids);
        }

        /** @var array<string> $salesChannelIds */
        $salesChannelIds = $this->salesChannelRepository->searchIds($criteria$context)->getIds();

        if (empty($salesChannelIds)) {
            $output->write('No sales channels were updated');

            return self::SUCCESS;
        }

        
#[Route(path: '/store-api/product/{productId}', name: 'store-api.product.detail', methods: ['POST'], defaults: ['_entity' => 'product'])]     public function load(string $productId, Request $request, SalesChannelContext $context, Criteria $criteria): ProductDetailRouteResponse
    {
        return Profiler::trace('product-detail-route', function D) use ($productId$request$context$criteria) {
            $mainVariantId = $this->checkVariantListingConfig($productId$context);

            $productId = $mainVariantId ?? $this->findBestVariant($productId$context);

            $this->addFilters($context$criteria);

            $criteria->setIds([$productId]);
            $criteria->setTitle('product-detail-route');

            $product = $this->productRepository
                ->search($criteria$context)
                ->first();

            if (!($product instanceof SalesChannelProductEntity)) {
                throw new ProductNotFoundException($productId);
            }

            $product->setSeoCategory(
                
public function handle(EntityIndexingMessage $message): void
    {
        $ids = $message->getData();
        $ids = array_unique(array_filter($ids));
        if (empty($ids)) {
            return;
        }

        $criteria = new Criteria();
        $criteria->addAssociation('mediaThumbnailSizes');
        $criteria->setIds($ids);

        $context = $message->getContext();

        /** @var MediaFolderConfigurationCollection $configs */
        $configs = $this->repository->search($criteria$context);

        $update = new RetryableQuery(
            $this->connection,
            $this->connection->prepare('UPDATE media_folder_configuration SET media_thumbnail_sizes_ro = :media_thumbnail_sizes_ro WHERE id = :id')
        );

        

        ];

        yield 'Email Newsletter Recipient Registered' => [
            function DContext $context, string $email, self $me): array {
                $newsletterRecipientId = $me->createNewsletterRecipient($context$email, TestDefaults::SALES_CHANNEL);

                return [
                    $newsletterRecipientId,
                ];
            },
            fn (Criteria $criteria, array $ids): Criteria => $criteria->setIds($ids),
        ];

        yield 'Email Newsletter Recipient Registered Multiple' => [
            function DContext $context, string $email, self $me): array {
                $salesChannel = $me->createSalesChannel();

                $newsletterRecipientId = $me->createNewsletterRecipient($context$email, TestDefaults::SALES_CHANNEL);
                $newsletterRecipientId2 = $me->createNewsletterRecipient($context$email$salesChannel['id']);

                return [
                    $newsletterRecipientId,
                    

    }

    public function getDecorated(): AbstractCustomerRoute
    {
        throw new DecorationPatternException(self::class);
    }

    #[Route(path: '/store-api/account/customer', name: 'store-api.account.customer', methods: ['GET', 'POST'], defaults: ['_loginRequired' => true, '_loginRequiredAllowGuest' => true, '_entity' => 'customer'])]     public function load(Request $request, SalesChannelContext $context, Criteria $criteria, CustomerEntity $customer): CustomerResponse
    {
        $criteria->setIds([$customer->getId()]);

        $customerEntity = $this->customerRepository->search($criteria$context->getContext())->first();

        return new CustomerResponse($customerEntity);
    }
}
Home | Imprint | This part of the site doesn't use cookies.