EqualsAnyFilter example

$ids = array_values($collection->getIds());

        $isInheritanceAware = $definition->isInheritanceAware() && $context->considerInheritance();

        if ($isInheritanceAware) {
            $parentIds = array_values(\array_filter($collection->map(fn (Entity $entity) => $entity->get('parentId'))));

            $ids = array_unique([...$ids, ...$parentIds]);
        }

        $fieldCriteria->addFilter(new EqualsAnyFilter($propertyAccessor$ids));

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

        if ($partial !== []) {
            // Make sure our collection index will be loaded             $partial[$propertyName] = [];
            $collectionClass = EntityCollection::class;
        }

        


        $criteria = (new Criteria())
            ->addFilter(new EqualsFilter('name', $rawInput));

        $searchResult = $this->mediaFolderRepository->search($criteria$context);

        if ($searchResult->getTotal() === 0) {
            throw MediaException::mediaFolderNameNotFound($rawInput);
        }

        return new EqualsAnyFilter('mediaFolderId', $searchResult->getIds());
    }

    /** * @param RepositoryIterator<MediaCollection> $iterator * * @return array<string, int|array<array<string>>> */
    private function generateThumbnails(RepositoryIterator $iterator, Context $context): array
    {
        $generated = 0;
        $skipped = 0;
        
string $salesChannelId
    ) {
        $activeDateRange = new ActiveDateRange();

        parent::__construct(
            MultiFilter::CONNECTION_AND,
            [new EqualsFilter('active', true),
                new EqualsFilter('promotion.salesChannels.salesChannelId', $salesChannelId),
                $activeDateRange,
                new EqualsFilter('useCodes', true),
                new EqualsFilter('useIndividualCodes', false),
                new EqualsAnyFilter('code', $codes),
            ]
        );
    }
}
foreach ($event->getWriteResults() as $writeResult) {
            /** @var array<string, string> $pk */
            $pk = $writeResult->getPrimaryKey();
            $ids[] = $pk['customerGroupId'];
        }

        if (\count($ids) === 0) {
            return;
        }

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsAnyFilter('foreignKey', $ids));
        $criteria->addFilter(new EqualsFilter('routeName', self::ROUTE_NAME));

        /** @var array<string> $ids */
        $ids = array_values($this->seoUrlRepository->searchIds($criteria$event->getContext())->getIds());

        if (\count($ids) === 0) {
            return;
        }

        $this->seoUrlRepository->delete(array_map(fn (string $id) => ['id' => $id]$ids)$event->getContext());
    }

    
$this->faker = $context->getFaker();

        /** @var list<string> $paymentMethodIds */
        $paymentMethodIds = $this->paymentMethodRepository->searchIds(new Criteria()$context->getContext())->getIds();
        /** @var list<string> $shippingMethodIds */
        $shippingMethodIds = $this->shippingMethodRepository->searchIds(new Criteria()$context->getContext())->getIds();

        $criteria = (new Criteria())->addFilter(
            new NotFilter(
                NotFilter::CONNECTION_AND,
                [
                    new EqualsAnyFilter('rule.shippingMethods.id', $shippingMethodIds),
                    new EqualsAnyFilter('rule.paymentMethods.id', $paymentMethodIds),
                ]
            )
        );

        $ids = $this->ruleRepository->searchIds($criteria$context->getContext());

        if (!empty($ids->getIds())) {
            return;
        }

        

    private function getEntities(array $plugins, Context $context): EntitySearchResult
    {
        $names = array_map(static fn (Plugin $plugin) => $plugin->getName()$plugins);

        return $this->pluginRepo->search(
            (new Criteria())->addFilter(new EqualsAnyFilter('name', $names)),
            $context
        );
    }

    private function executeComposerRequireWhenNeeded(PluginEntity $plugin, Plugin $pluginBaseClass, string $pluginVersion, Context $shopwareContext): bool
    {
        $pluginComposerName = $plugin->getComposerName();
        if ($pluginComposerName === null) {
            throw new PluginComposerJsonInvalidException(
                $pluginBaseClass->getPath() . '/composer.json',
                ['No name defined in composer.json']
            );
'multi_match' => [
                    'query' => 'foo',
                    'fields' => [
                        'name.' . self::SECOND_LANGUAGE,
                        'name.' . Defaults::LANGUAGE_SYSTEM,
                    ],
                    'type' => 'best_fields',
                ],
            ],
        ];
        yield 'EqualsAnyFilter field' => [
            new EqualsAnyFilter('productNumber', ['foo', 'bar']),
            [
                'terms' => [
                    'productNumber' => ['foo', 'bar'],
                ],
            ],
        ];
        yield 'EqualsAnyFilter translated field' => [
            new EqualsAnyFilter('name', ['foo', 'bar']),
            [
                'dis_max' => [
                    'queries' => [
                        [
public function __invoke(GenerateThumbnailsMessage|UpdateThumbnailsMessage $msg): void
    {
        if (Feature::isActive('v6.6.0.0')) {
            $context = $msg->getContext();
        } else {
            $context = $msg->readContext();
        }

        $criteria = new Criteria();
        $criteria->addAssociation('mediaFolder.configuration.mediaThumbnailSizes');
        $criteria->addFilter(new EqualsAnyFilter('media.id', $msg->getMediaIds()));

        /** @var MediaCollection $entities */
        $entities = $this->mediaRepository->search($criteria$context)->getEntities();

        if ($msg instanceof UpdateThumbnailsMessage) {
            foreach ($entities as $media) {
                $this->thumbnailService->updateThumbnails($media$context$msg->isStrict());
            }
        } else {
            $this->thumbnailService->generate($entities$context);
        }
    }
$criteria->setTitle('product::cms-page');

        $slots = $request->get('slots');

        if (\is_string($slots)) {
            $slots = explode('|', $slots);
        }

        if (!empty($slots) && \is_array($slots)) {
            $criteria
                ->getAssociation('sections.blocks')
                ->addFilter(new EqualsAnyFilter('slots.id', $slots));
        }

        return $criteria;
    }
}
$criteria = new Criteria([$id]);

        $slots = $request->get('slots');

        if (\is_string($slots)) {
            $slots = explode('|', $slots);
        }

        if (!empty($slots)) {
            $criteria
                ->getAssociation('sections.blocks')
                ->addFilter(new EqualsAnyFilter('slots.id', $slots));
        }

        $pages = $this->cmsPageLoader->load($request$criteria$context);

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

        return new CmsRouteResponse($pages->get($id));
    }
}
$criteria->setTitle('category::cms-page');

        $slots = $request->get('slots');

        if (\is_string($slots)) {
            $slots = explode('|', $slots);
        }

        if (!empty($slots) && \is_array($slots)) {
            $criteria
                ->getAssociation('sections.blocks')
                ->addFilter(new EqualsAnyFilter('slots.id', $slots));
        }

        return $criteria;
    }
}
foreach ($defaultFolder->getAssociationFields() as $associationField) {
                    $criteria->addFilter(
                        new EqualsFilter("media.{$associationField}.id", null)
                    );
                }
            }
        }

        $extension = $context->getExtension(self::RESTRICT_DEFAULT_FOLDER_ENTITIES_EXTENSION);
        if ($extension instanceof ArrayStruct) {
            $criteria->addFilter(
                new EqualsAnyFilter('media.mediaFolder.defaultFolder.entity', $extension->all())
            );
        }

        return $criteria;
    }

    private function isNoAssociation(MediaDefaultFolderEntity $defaultFolder): bool
    {
        $folder = $defaultFolder->getFolder();
        \assert($folder !== null);

        
static::assertContains($ids->get('with-avatar')$media->getIds());
        static::assertContains($ids->get('without-avatar')$media->getIds());
    }

    /** * @depends testIndexing */
    public function testAggregationWithFilter(IdsCollection $ids): void
    {
        $criteria = new Criteria();
        $criteria->addFilter(
            new EqualsAnyFilter('properties.id', $ids->getList(['red']))
        );

        $criteria->addAggregation(
            new TermsAggregation('filters', 'properties.id')
        );

        $criteria->setLimit(0);

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

        
'stock' => 10,
                'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => 15, 'net' => 10, 'linked' => false]],
                'manufacturer' => ['name' => 'test'],
                'tax' => ['name' => 'test', 'taxRate' => 15],
            ],
        ];

        $context = Context::createDefaultContext();
        $this->productRepository->create($products$context);

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsAnyFilter('product.id', [$id1$id2]));
        $criteria->addQuery(
            new ScoreQuery(new ContainsFilter('product.name', 'matching'), 1000)
        );
        $criteria->addQuery(
            new ScoreQuery(new ContainsFilter('product.name', 'test matching'), 1000)
        );

        $criteria->addQuery(
            new ScoreQuery(new ContainsFilter('product.name', 'matching product'), 1000)
        );

        
if ($fkey === null) {
                continue;
            }

            $criteria->addFilter(
                new EqualsFilter(sprintf('media.%s.%s', $field->getPropertyName()$fkey->getPropertyName()), null)
            );
        }

        if ($folderEntity) {
            $criteria->addFilter(
                new EqualsAnyFilter('media.mediaFolder.defaultFolder.entity', [strtolower($folderEntity)])
            );
        }

        return $criteria;
    }
}
Home | Imprint | This part of the site doesn't use cookies.