getIds example

 elseif ($item instanceof Struct) {
                $this->findStruct($data$item);
            }
        }
    }

    private function enrich(SeoResolverData $data, SalesChannelContext $context): void
    {
        foreach ($data->getEntities() as $definition) {
            $definition = (string) $definition;

            $ids = $data->getIds($definition);
            $routes = $this->seoUrlRouteRegistry->findByDefinition($definition);
            if (\count($routes) === 0) {
                continue;
            }

            $routes = array_map(static fn (SeoUrlRouteConfigRoute $seoUrlRoute) => $seoUrlRoute->getConfig()->getRouteName()$routes);

            $criteria = new Criteria();
            $criteria->addFilter(new EqualsFilter('isCanonical', true));
            $criteria->addFilter(new EqualsAnyFilter('routeName', $routes));
            $criteria->addFilter(new EqualsAnyFilter('foreignKey', $ids));
            

            'testSearchFilter' => [
                [
                    'filter' => [
                        ['type' => 'equals', 'field' => 'childCount', 'value' => 0],
                    ],
                ],
                'search',
                $ids,
                function DEntitySearchResult $result) use ($ids): void {
                    static::assertCount(1, $result);
                    static::assertContains($ids->get('p3')$result->getIds());
                },
            ],
            'testSearchRead' => [
                [
                    'ids' => [$ids->get('p1')$ids->get('p2')],
                ],
                'search',
                $ids,
                function DEntitySearchResult $result) use ($ids): void {
                    static::assertCount(1, $result);
                    static::assertContains($ids->get('p1')$result->getIds());
                },

        $maxLifeTime = $this->getUnusedGuestCustomerLifeTime();

        if (!$maxLifeTime) {
            return [];
        }

        $criteria = $this->getUnusedCustomerCriteria($maxLifeTime);
        $criteria->setLimit(self::DELETE_CUSTOMERS_BATCH_SIZE);

        /** @var list<string> $ids */
        $ids = $this->customerRepository->searchIds($criteria$context)->getIds();
        $ids = \array_values(\array_map(static fn (string $id) => ['id' => $id]$ids));

        $this->customerRepository->delete($ids$context);

        return $ids;
    }

    private function getUnusedCustomerCriteria(\DateTime $maxLifeTime): Criteria
    {
        $criteria = new Criteria();

        
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\System\SalesChannel\SalesChannelContext;

#[Package('checkout')] trait CustomerAddressValidationTrait
{
    private function validateAddress(string $id, SalesChannelContext $context, CustomerEntity $customer): void
    {
        $criteria = new Criteria([$id]);
        $criteria->addFilter(new EqualsFilter('customerId', $customer->getId()));

        if (\count($this->addressRepository->searchIds($criteria$context->getContext())->getIds())) {
            return;
        }

        throw CustomerException::addressNotFound($id);
    }
}
return array_map(EntityCacheKeyGenerator::buildStreamTag(...)$ids);
    }

    /** * @return array<string> */
    private function extractProductIds(ProductCrossSellingRouteResponse $response): array
    {
        $ids = [];

        foreach ($response->getResult() as $element) {
            $ids = [...$ids, ...$element->getProducts()->getIds()];
        }

        $ids = array_unique(array_filter($ids));

        return array_map(EntityCacheKeyGenerator::buildProductTag(...)$ids);
    }
}
$orderData = $this->getOrderData($orderId$defaultContext);

        unset($orderData[0]['orderCustomer']['customer']);

        $this->orderRepository->create($orderData$defaultContext);

        $this->orderRepository->delete([['id' => $orderId]]$defaultContext);

        $criteria = new Criteria([$orderId]);
        $order = $this->orderRepository->searchIds($criteria$defaultContext);

        static::assertEmpty($order->getIds());
    }

    public function testDeleteOrder(): void
    {
        $token = Uuid::randomHex();
        $cart = new Cart($token);

        $id = Uuid::randomHex();

        $product = [
            'id' => $id,
            
$chain[] = $root . '.translation';
        if ($includeParent) {
            $chain[] = $root . '.parent.translation';
        }

        return $chain;
    }

    public function addIdCondition(Criteria $criteria, EntityDefinition $definition, QueryBuilder $query): void
    {
        $primaryKeys = $criteria->getIds();

        $primaryKeys = array_values($primaryKeys);

        if (empty($primaryKeys)) {
            return;
        }

        if (!\is_array($primaryKeys[0]) || \count($primaryKeys[0]) === 1) {
            $primaryKeyField = $definition->getPrimaryKeys()->first();
            if ($primaryKeyField instanceof IdField || $primaryKeyField instanceof FkField) {
                $primaryKeys = array_map(function D$id) {
                    


    private function getCommits(string $versionId, WriteContext $writeContext): VersionCommitCollection
    {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('version_commit.versionId', $versionId));
        $criteria->addSorting(new FieldSorting('version_commit.autoIncrement'));
        $commitIds = $this->entitySearcher->search($this->versionCommitDefinition, $criteria$writeContext->getContext());

        $readCriteria = new Criteria();
        if ($commitIds->getTotal() > 0) {
            $readCriteria = new Criteria($commitIds->getIds());
        }

        $readCriteria->addAssociation('data');

        $readCriteria
            ->getAssociation('data')
            ->addSorting(new FieldSorting('autoIncrement'));

        /** @var VersionCommitCollection $commits */
        $commits = $this->entityReader->read($this->versionCommitDefinition, $readCriteria$writeContext->getContext());

        

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('categoryIds', null));

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

        $productsWithoutCategory = [
            $this->ids->get('product1-without-category'),
            $this->ids->get('product2-without-category'),
        ];

        static::assertEquals($productsWithoutCategory$result->getIds());
    }

    public function testFindProductsWithCategory(): void
    {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('categoryIds', $this->ids->get('category1')));

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

        $productsWithoutCategory = [
            $this->ids->get('product1-with-category'),
        ];
$this->deleteOldScripts($existingScripts$context);
    }

    public function activateAppScripts(string $appId, Context $context): void
    {
        $criteria = new Criteria();
        $criteria->setTitle('app-scripts::activate');
        $criteria->addFilter(new EqualsFilter('appId', $appId));
        $criteria->addFilter(new EqualsFilter('active', false));

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

        $updateSet = array_map(fn (string $id) => ['id' => $id, 'active' => true]$scripts);

        $this->scriptRepository->update($updateSet$context);
    }

    public function deactivateAppScripts(string $appId, Context $context): void
    {
        $criteria = new Criteria();
        $criteria->setTitle('app-scripts::deactivate');
        $criteria->addFilter(new EqualsFilter('appId', $appId));
        
if (!empty($upserts)) {
            $this->cmsBlockRepository->upsert($upserts$context);
        }

        $this->deleteOldCmsBlocks($existingCmsBlocks$context);
    }

    private function deleteOldCmsBlocks(AppCmsBlockCollection $toBeRemoved, Context $context): void
    {
        /** @var array<string> $ids */
        $ids = $toBeRemoved->getIds();

        if (!empty($ids)) {
            $ids = array_map(static fn (string $id): array => ['id' => $id]array_values($ids));

            $this->cmsBlockRepository->delete($ids$context);
        }
    }

    private function getExistingCmsBlocks(string $appId, Context $context): AppCmsBlockCollection
    {
        $criteria = new Criteria();
        
/** * Helper to assert IDs structure. * * @param \Drupal\migrate\Plugin\MigrateSourceInterface $source * The source plugin. * @param array $configuration * The source plugin configuration (Nope, no getter available). * * @internal */
  protected function assertIds(MigrateSourceInterface $source, array $configuration): void {
    $ids = $source->getIds();
    [$entity_type_id] = explode(PluginBase::DERIVATIVE_SEPARATOR, $source->getPluginId());
    $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);

    $this->assertArrayHasKey($entity_type->getKey('id')$ids);
    $ids_count_expected = 1;

    if ($entity_type->isTranslatable()) {
      $ids_count_expected++;
      $this->assertArrayHasKey($entity_type->getKey('langcode')$ids);
    }

    
if (!$productIds instanceof DataBag) {
            throw CustomerException::productIdsParameterIsMissing();
        }

        $ids = array_unique(array_filter($productIds->all()));

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

        /** @var array<string> $ids */
        $ids = $this->productRepository->searchIds(new Criteria($ids)$context)->getIds();

        $customerProducts = $this->loadCustomerProducts($wishlistId$ids);

        $upsertData = [];

        /** @var string $id * */
        foreach ($ids as $id) {
            if (\array_key_exists($id$customerProducts)) {
                $upsertData[] = [
                    'id' => $customerProducts[$id],
                ];

                
return [];
        }

        if (null !== $countryCode) {
            try {
                return Timezones::forCountryCode($countryCode);
            } catch (MissingResourceException) {
                return [];
            }
        }

        $timezones = Timezones::getIds();

        if (\DateTimeZone::ALL === (\DateTimeZone::ALL & $zone)) {
            return $timezones;
        }

        $filtered = [];
        foreach ((new \ReflectionClass(\DateTimeZone::class))->getConstants() as $const => $flag) {
            if ($flag !== ($flag & $zone)) {
                continue;
            }

            
return $data['accessKey'];
    }

    private function getFirstActiveShippingMethodId(): string
    {
        $criteria = (new Criteria())
            ->setLimit(1)
            ->addFilter(new EqualsFilter('active', true));

        /** @var array<string> $ids */
        $ids = $this->shippingMethodRepository->searchIds($criteria, Context::createDefaultContext())->getIds();

        return $ids[0];
    }

    private function getFirstActivePaymentMethodId(): string
    {
        $criteria = (new Criteria())
            ->setLimit(1)
            ->addFilter(new EqualsFilter('active', true))
            ->addSorting(new FieldSorting('position'));

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