NotFilter example

private function getCustomerByEmail(string $customerId, string $email, Context $context, ?string $boundSalesChannelId): ?CustomerEntity
    {
        $criteria = new Criteria();
        $criteria->setLimit(1);
        if ($boundSalesChannelId) {
            $criteria->addAssociation('boundSalesChannel');
        }

        $criteria->addFilter(new EqualsFilter('email', $email));
        $criteria->addFilter(new EqualsFilter('guest', false));
        $criteria->addFilter(new NotFilter(
            NotFilter::CONNECTION_AND,
            [new EqualsFilter('id', $customerId)]
        ));

        $criteria->addFilter(new MultiFilter(MultiFilter::CONNECTION_OR, [
            new EqualsFilter('boundSalesChannelId', null),
            new EqualsFilter('boundSalesChannelId', $boundSalesChannelId),
        ]));

        /** @var ?CustomerEntity $customer */
        $customer = $this->customerRepo->search($criteria$context)->first();

        


    public function run(): void
    {
        $sitemapRefreshStrategy = $this->systemConfigService->getInt('core.sitemap.sitemapRefreshStrategy');
        if ($sitemapRefreshStrategy !== SitemapExporterInterface::STRATEGY_SCHEDULED_TASK) {
            return;
        }

        $criteria = new Criteria();
        $criteria->addAssociation('domains');
        $criteria->addFilter(new NotFilter(
            NotFilter::CONNECTION_AND,
            [new EqualsFilter('domains.id', null)]
        ));

        $criteria->addAssociation('type');
        $criteria->addFilter(new EqualsFilter('type.id', Defaults::SALES_CHANNEL_TYPE_STOREFRONT));

        $context = Context::createDefaultContext();

        $this->eventDispatcher->dispatch(
            new SitemapSalesChannelCriteriaEvent($criteria$context)
        );
$this->getTaggedProduct($greenId, 'green', ['green']),
            $this->getTaggedProduct($redGreenId, 'red and green', ['red', 'green']),
            $this->getTaggedProduct($blueId, 'blue', ['blue']),
        ];

        $ids = array_column($products, 'id');

        /** @var EntityRepository $productRepository */
        $productRepository = $this->getContainer()->get('product.repository');
        $productRepository->create($products, Context::createDefaultContext());

        $notGreenFilter = new NotFilter('AND', [
            new EqualsFilter('product.tags.name', 'green'),
        ]);
        $criteria = (new Criteria($ids))
            ->addFilter($notGreenFilter);

        $notGreenIds = $productRepository->searchIds($criteria, Context::createDefaultContext())->getIds();
        static::assertContains($noTagsId$notGreenIds);
        static::assertContains($redId$notGreenIds);
        static::assertContains($blueId$notGreenIds);
        static::assertCount(3, $notGreenIds);

        
$context = Context::createDefaultContext();
        $context->addState(EntityIndexerRegistry::DISABLE_INDEXING);

        $progress = $this->import($context, ProductDefinition::ENTITY_NAME, '/fixtures/products_with_variants.csv', 'products.csv');

        static::assertImportExportSucceeded($progress$this->getInvalidLogContent($progress->getInvalidRecordsLogId()));
        static::assertEquals(2, $progress->getProcessedRecords());

        $criteria = new Criteria();
        $criteria->addAssociation('options.group');
        $criteria->addFilter(new NotFilter(NotFilter::CONNECTION_AND, [new EqualsFilter('parentId', null)]));

        $products = $this->productRepository->search($criteria, Context::createDefaultContext())->getEntities();

        static::assertInstanceOf(ProductCollection::class$products);
        static::assertEquals(32, $products->count());
        static::assertInstanceOf(ProductEntity::class$product = $products->first());
        static::assertCount(3, $product->getVariation());
        static::assertContains('color', array_column($product->getVariation(), 'group'));
        static::assertContains('size', array_column($product->getVariation(), 'group'));
        static::assertContains('material', array_column($product->getVariation(), 'group'));

        


        $criteria = new Criteria();
        $criteria->addFilter(...$filters);
        $criteria->setLimit($limit);
        $criteria->addAssociation('options.group');
        $criteria->addAssociation('manufacturer');

        // Ensure storefront presentation settings of product variants         $criteria->addGroupField(new FieldGrouping('displayGroup'));
        $criteria->addFilter(
            new NotFilter(
                NotFilter::CONNECTION_AND,
                [new EqualsFilter('displayGroup', null)]
            )
        );

        if ($sorting === 'random') {
            return $this->addRandomSort($criteria);
        }

        if ($sorting) {
            $sorting = explode(':', $sorting);
            
 {
    }

    /** * @return array<string|int, mixed> */
    public function getCookieGroups(): array
    {
        $criteria = new Criteria();
        $criteria->addFilter(
            new EqualsFilter('active', true),
            new NotFilter(
                NotFilter::CONNECTION_AND,
                [
                    new EqualsFilter('app.cookies', null),
                ]
            )
        );

        $result = $this->appRepository->search(
            $criteria,
            Context::createDefaultContext()
        )->getEntities();

        


        $this->createProduct($id2[
            ['id' => $green, 'name' => 'green'],
            ['id' => $red, 'name' => 'red'],
        ]);

        $context = Context::createDefaultContext();

        $criteria = new Criteria();
        $criteria->addFilter(
            new NotFilter(NotFilter::CONNECTION_OR, [
                new EqualsAnyFilter('product.tagIds', [$notAssigned]),
            ])
        );
        $ids = $this->repository->searchIds($criteria$context);

        static::assertContains($id1$ids->getIds());
        static::assertContains($id2$ids->getIds());

        $criteria = new Criteria();
        $criteria->addFilter(
            new NotFilter(NotFilter::CONNECTION_OR, [
                
$orderData[0]['lineItems'][0]['identifier'] = $productId;
        $orderData[0]['lineItems'][0]['productId'] = $productId;

        $orderRepo = $this->getContainer()->get('order.repository');
        $orderRepo->create($orderData$context);

        // Change default SalesChannel ShippingMethod to another than the ordered one         $orderShippingMethodId = $orderData[0]['deliveries'][0]['shippingMethodId'];
        $criteria = new Criteria();
        $criteria->setLimit(1);
        $criteria->addFilter(
            new NotFilter(NotFilter::CONNECTION_AND, [
                new EqualsFilter('id', $orderShippingMethodId),
            ]),
            new EqualsFilter('active', true)
        );
        $differentShippingMethodId = $this->getContainer()->get('shipping_method.repository')->searchIds($criteria$context)->firstId();
        static::assertNotNull($differentShippingMethodId);
        static::assertNotSame($orderShippingMethodId$differentShippingMethodId);
        $salesChannelRepository->update([
            [
                'id' => $salesChannel->getId(),
                'shippingMethodId' => $differentShippingMethodId,
                

    public function checkEmailUnique(string $userEmail, string $userId, Context $context): bool
    {
        $criteria = new Criteria();

        $criteria->addFilter(
            new MultiFilter(
                'AND',
                [
                    new EqualsFilter('email', $userEmail),
                    new NotFilter('AND', [
                        new EqualsFilter('id', $userId),
                    ]),
                ]
            )
        );

        return $this->userRepo->searchIds($criteria$context)->getTotal() === 0;
    }

    /** * @throws InconsistentCriteriaIdsException */
private function checkDocumentNumberAlreadyExits(
        string $documentTypeName,
        string $documentNumber,
        Context $context,
        ?string $documentId = null
    ): void {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('documentType.technicalName', $documentTypeName));
        $criteria->addFilter(new EqualsFilter('config.documentNumber', $documentNumber));

        if ($documentId !== null) {
            $criteria->addFilter(new NotFilter(
                NotFilter::CONNECTION_AND,
                [new EqualsFilter('id', $documentId)]
            ));
        }

        $criteria->setLimit(1);

        $result = $this->documentRepository->searchIds($criteria$context);

        if ($result->getTotal() !== 0) {
            throw new DocumentNumberAlreadyExistsException($documentNumber);
        }
private function getNewMediaEntities(): MediaCollection
    {
        if (!empty($this->initialMediaIds)) {
            $criteria = new Criteria($this->initialMediaIds);
            $result = $this->mediaRepository->searchIds($criteria$this->context);
            static::assertEquals(\count($this->initialMediaIds)$result->getTotal());
        }

        $criteria = new Criteria();
        $criteria->addAssociation('thumbnails');
        if (!empty($this->initialMediaIds)) {
            $criteria->addFilter(new NotFilter(
                NotFilter::CONNECTION_AND,
                [
                    new EqualsAnyFilter('id', $this->initialMediaIds),
                ]
            ));
        }

        return $this->mediaRepository->search($criteria$this->context)->getEntities();
    }
}
string $fileName,
        string $fileExtension,
        ?string $mediaId,
        Context $context
    ): MediaCollection {
        $criteria = new Criteria();
        $criteria->addFilter(new MultiFilter(
            MultiFilter::CONNECTION_AND,
            [
                new ContainsFilter('fileName', $fileName),
                new EqualsFilter('fileExtension', $fileExtension),
                new NotFilter(NotFilter::CONNECTION_AND, [new EqualsFilter('id', $mediaId)]),
            ]
        ));

        $search = $this->mediaRepository->search($criteria$context);

        /** @var MediaCollection $mediaCollection */
        $mediaCollection = $search->getEntities();

        return $mediaCollection;
    }

    

        $data = $this->getSalesChannelData($id);

        $this->getContainer()->get('sales_channel.repository')->create([$data], Context::createDefaultContext());
    }

    private function getNonSystemLanguageId(): string
    {
        /** @var EntityRepository $languageRepository */
        $languageRepository = $this->getContainer()->get('language.repository');
        $criteria = new Criteria();
        $criteria->addFilter(new NotFilter(
            MultiFilter::CONNECTION_AND,
            [
                new EqualsFilter('id', Defaults::LANGUAGE_SYSTEM),
            ]
        ));
        $criteria->setLimit(1);

        $id = $languageRepository->searchIds($criteria, Context::createDefaultContext())->firstId();
        static::assertIsString($id);

        return $id;
    }
$keyProp->setValue($item$key);
        $valueProp->setValue($item$value);
        $isHitProp->setValue($item$isHit);

        return $item;
    }

    private function storefontSalesChannelCriteria(array $ids): Criteria
    {
        $criteria = new Criteria($ids);
        $criteria->addAssociation('domains');
        $criteria->addFilter(new NotFilter(
            NotFilter::CONNECTION_AND,
            [new EqualsFilter('domains.id', null)]
        ));

        $criteria->addAssociation('type');
        $criteria->addFilter(new EqualsFilter('type.id', Defaults::SALES_CHANNEL_TYPE_STOREFRONT));

        return $criteria;
    }

    private function generateSitemap(SalesChannelContext $salesChannelContext, bool $force, ?string $lastProvider = null, ?int $offset = null): void
    {


    private function getTokenFromSystem(Context $context): ?string
    {
        $contextSource = $context->getSource();
        if (!($contextSource instanceof SystemSource)) {
            throw new InvalidContextSourceException(SystemSource::class$contextSource::class);
        }

        $criteria = new Criteria();
        $criteria->addFilter(
            new NotFilter(NotFilter::CONNECTION_OR, [new EqualsFilter('storeToken', null)])
        );

        return $this->fetchUserStoreToken($criteria$context);
    }

    private function fetchUserStoreToken(Criteria $criteria, Context $context): ?string
    {
        /** @var UserEntity|null $user */
        $user = $this->userRepository->search($criteria$context)->first();

        if ($user === null) {
            
Home | Imprint | This part of the site doesn't use cookies.