addAssociation example

$this->getReader($logEntity),
            $this->getWriter($logEntity),
            $this->fileService,
            $importBatchSize,
            $exportBatchSize
        );
    }

    private function findLog(string $logId): ImportExportLogEntity
    {
        $criteria = new Criteria([$logId]);
        $criteria->addAssociation('profile');
        $criteria->addAssociation('file');
        $criteria->addAssociation('invalidRecordsLog.file');
        $logEntity = $this->logRepository->search($criteria, Context::createDefaultContext())->first();

        if ($logEntity === null) {
            throw new ProcessingException('LogEntity not found');
        }

        return $logEntity;
    }

    
'bodyTemplate' => 'test',
                'productStreamId' => '137b079935714281ba80b40f83f8d7eb',
                'storefrontSalesChannelId' => TestDefaults::SALES_CHANNEL,
                'salesChannelId' => $this->getSalesChannelId(),
                'salesChannelDomainId' => $this->getSalesChannelDomainId(),
                'generateByCronjob' => false,
                'currencyId' => Defaults::CURRENCY,
            ],
        ]$this->context);

        $criteria = new Criteria([$id]);
        $criteria->addAssociation('productStream');
        $entity = $this->repository->search($criteria$this->context)->get($id);

        static::assertNotNull($entity->getProductStream());
    }

    public function testFetchSalesChannel(): void
    {
        $id = Uuid::randomHex();
        $this->repository->upsert([
            [
                'id' => $id,
                
static::assertEquals('new-license-domain', $queries['domain']);
    }

    private function getLanguageFromContext(Context $context): string
    {
        /** @var AdminApiSource $contextSource */
        $contextSource = $context->getSource();
        $userId = $contextSource->getUserId();

        static::assertIsString($userId);

        $criteria = (new Criteria([$userId]))->addAssociation('locale');

        $user = $this->getUserRepository()->search($criteria$context)->first();

        return $user->getLocale()->getCode();
    }
}


        // Test fetch         $fetchedEntityOne = $testEntityOneRepository->search(
            (new Criteria())->addFilter(new EqualsFilter('technicalName', 'Some-Technical-Name')),
            $context,
        );
        static::assertNotNull($fetchedEntityOne);
        $fetchedEntityTwo = $testEntityTwoRepository->search(
            (new Criteria())
                ->addFilter(new EqualsFilter('id', $testEntityTwoId))
                ->addAssociation('testEntityOne'),
            $context,
        );
        static::assertNotNull($fetchedEntityTwo);

        // Test deletion         $testEntityOneRepository->delete([['technicalName' => 'Some-Technical-Name']]$context);
        $testEntityTwoRepository->delete([['id' => $testEntityTwoId]]$context);

        // Clean up         $this->connection->executeStatement(
            'DROP TABLE `test_entity_two`; DROP TABLE `test_entity_one`;',
self::OPTION_DIRECT => $this->isNewsletterDoi($context) ? self::STATUS_NOT_SET : self::STATUS_DIRECT,
            self::OPTION_SUBSCRIBE => $this->isNewsletterDoi($context) ? self::STATUS_NOT_SET : self::STATUS_DIRECT,
            self::OPTION_CONFIRM_SUBSCRIBE => self::STATUS_OPT_IN,
            self::OPTION_UNSUBSCRIBE => self::STATUS_OPT_OUT,
        ];
    }

    private function getNewsletterRecipient(string $identifier, string $value, Context $context): NewsletterRecipientEntity
    {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter($identifier$value));
        $criteria->addAssociation('salutation');
        $criteria->setLimit(1);

        /** @var NewsletterRecipientEntity|null $newsletterRecipient */
        $newsletterRecipient = $this->newsletterRecipientRepository->search($criteria$context)->getEntities()->first();

        if (!$newsletterRecipient) {
            throw NewsletterException::recipientNotFound($identifier$value);
        }

        return $newsletterRecipient;
    }

    
static::assertTrue($eventDidRun, 'The mail.sent Event did not run');
        $this->salesChannelContext = $previousContext;
    }

    public function testOrderTransactionStateTransition(): void
    {
        $orderId = $this->performOrder();

        // getting the id of the order transaction         $criteria = new Criteria([$orderId]);

        $criteria->addAssociation('transactions.stateMachineState');

        /** @var OrderEntity $order */
        $order = $this->orderRepository->search($criteria$this->salesChannelContext->getContext())->first();
        static::assertNotNull($transactions = $order->getTransactions());
        static::assertNotNull($transaction = $transactions->first());
        $orderTransactionId = $transaction->getId();

        $this->orderService->orderTransactionStateTransition(
            $orderTransactionId,
            'remind',
            new RequestDataBag(),
            
->firstId();

        static::assertNotNull($mailTemplateId);

        $config = array_filter([
            'mailTemplateId' => $mailTemplateId,
            'recipient' => $recipients,
            'documentTypeIds' => $documentTypeIds,
        ]);

        $criteria = new Criteria([$orderId]);
        $criteria->addAssociation('transactions.stateMachineState');
        /** @var OrderEntity $order */
        $order = $orderRepository->search($criteria$context)->first();
        $event = new CheckoutOrderPlacedEvent($context$order, TestDefaults::SALES_CHANNEL);

        $documentIdOlder = null;
        $documentIdNewer = null;
        $documentIds = [];

        if ($documentTypeIds !== null && $documentTypeIds !== [] || $hasOrderSettingAttachment) {
            $documentIdOlder = $this->createDocumentWithFile($orderId$context);
            $documentIdNewer = $this->createDocumentWithFile($orderId$context);
            
$this->seoUrlRepository->delete(array_map(fn (string $id) => ['id' => $id]$ids)$event->getContext());
    }

    /** * @param list<string> $ids */
    private function createUrls(array $ids, Context $context): void
    {
        $criteria = new Criteria($ids);
        $criteria->addFilter(new EqualsFilter('registrationActive', true));

        $criteria->addAssociation('registrationSalesChannels.languages');
        $criteria->addAssociation('translations');

        if (Feature::isActive('v6.6.0.0')) {
            $criteria->getAssociation('registrationSalesChannels')->addFilter(
                new NandFilter([new EqualsFilter('typeId', Defaults::SALES_CHANNEL_TYPE_API)])
            );
        }

        /** @var CustomerGroupCollection $groups */
        $groups = $this->customerGroupRepository->search($criteria$context)->getEntities();
        $buildUrls = [];

        
$this->configFactory->createFromBundle(new Storefront()),
            $installConfig,
        ]);

        $this->themeLifecycleHandler->handleThemeInstallOrUpdate($installConfig$configs, Context::createDefaultContext());

        /** @var EntityRepository $themeRepository */
        $themeRepository = $this->getContainer()->get('theme.repository');
        $context = Context::createDefaultContext();
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('technicalName', 'ThemeWithMultiInheritance'));
        $criteria->addAssociation('parentThemes');
        /** @var ThemeEntity $theme */
        $theme = $themeRepository->search($criteria$context)->first();
    }

    public function testHandleThemeInstallOrUpdateWillRecompileOnlyTouchedTheme(): void
    {
        $salesChannelId = $this->createSalesChannel();
        $themeId = $this->createTheme('SimpleTheme', $salesChannelId);
        $installConfig = $this->configFactory->createFromBundle(new SimpleTheme());
        $installConfig->setStyleFiles(FileCollection::createFromArray(['onlyForFile']));

        
yield [['finalizeUrl' => 'https://foo.bar/finalize'], AppAsyncPaymentHandler::class];
        yield [['payUrl' => 'https://foo.bar/pay', 'finalizeUrl' => 'https://foo.bar/finalize'], AppAsyncPaymentHandler::class];
        yield [['validateUrl' => 'https://foo.bar/validate', 'captureUrl' => 'https://foo.bar/capture'], AppPaymentHandler::class];
        yield [['refundUrl' => 'https://foo.bar/refund'], AppPaymentHandler::class];
        yield [['payUrl' => 'https://foo.bar/pay', 'finalizeUrl' => 'https://foo.bar/finalize', 'validateUrl' => 'https://foo.bar/validate', 'captureUrl' => 'https://foo.bar/capture', 'refundUrl' => 'https://foo.bar/refund'], AppPaymentHandler::class];
    }

    private function getPaymentMethod(string $handler): PaymentMethodEntity
    {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('handlerIdentifier', $handler));
        $criteria->addAssociation('app');

        /** @var PaymentMethodEntity|null $method */
        $method = $this->paymentMethodRepository->search($criteria, Context::createDefaultContext())->first();

        if (!$method) {
            $method = [
                'id' => Uuid::randomHex(),
                'handlerIdentifier' => $handler,
                'translations' => [
                    Defaults::LANGUAGE_SYSTEM => [
                        'name' => $handler,
                    ],

            Defaults::CURRENCY,
            [Uuid::randomHex(), Uuid::randomHex(), Defaults::LANGUAGE_SYSTEM]
        );

        $context->setConsiderInheritance(true);

        // creates a select with 20x base tables         // original each table gets 3x translation tables as join table         // this results in a query of 79x joins         $criteria = new Criteria();
        $criteria->addAssociation('type');
        $criteria->addAssociation('language.locale');
        $criteria->addAssociation('language.translationCode');
        $criteria->addAssociation('customerGroup');
        $criteria->addAssociation('currency');
        $criteria->addAssociation('paymentMethod.media');
        $criteria->addAssociation('paymentMethod.media.mediaFolder');
        $criteria->addAssociation('paymentMethod.availabilityRule');
        $criteria->addAssociation('shippingMethod.media');
        $criteria->addAssociation('shippingMethod.media.mediaFolder');
        $criteria->addAssociation('shippingMethod.availabilityRule');
        $criteria->addAssociation('shippingMethod.deliveryTime');
        
protected function setUp(): void
    {
        parent::setUp();

        $contextFactory = $this->getContainer()->get(SalesChannelContextFactory::class);
        $this->salesChannelContext = $contextFactory->create('', TestDefaults::SALES_CHANNEL);
    }

    public function testGetHomeUrlSalesChannelIsExistingTwoDomain(): void
    {
        $criteria = new Criteria();
        $criteria->addAssociation('locale');
        $languages = $this->getContainer()->get('language.repository')->search($criteria$this->salesChannelContext->getContext())->getEntities();

        $domain = new SalesChannelDomainEntity();
        $domain->setId(Uuid::randomHex());
        $domain->setUrl('https://test-sitemap.de');
        $domain->setHreflangUseOnlyLocale(false);
        $domain->setLanguageId($languages->first()->getId());

        $this->salesChannelContext->getSalesChannel()->getDomains()->add($domain);

        $domain = new SalesChannelDomainEntity();
        

            );
        }

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

        if ($activeOnly) {
            $criteria->addFilter(new EqualsFilter('active', 1));
        }

        $criteria->addAssociation('themes');

        /** @var SalesChannelCollection $result */
        $result = $this->salesChannelRepository->search($criteria$context)->getEntities();

        $list = [];

        foreach ($result->getElements() as $salesChannel) {
            /** @var ThemeCollection|null $themes */
            $themes = $salesChannel->getExtensionOfType('themes', ThemeCollection::class);
            if (!$themes || !$theme = $themes->first()) {
                continue;
            }
$response = $browser->getResponse();

        /** @var OrderLineItemCollection $orderLineItemCollection */
        $orderLineItemCollection = $response->getData()['orderDetails'];

        foreach ($orderLineItemCollection as $orderLineItemEntity) {
            static::assertNull($orderLineItemEntity->getProduct());
        }

        $eventDispatcher = $this->getContainer()->get('event_dispatcher');
        $eventDispatcher->addListener(OrderRouteRequestEvent::classstatic function DOrderRouteRequestEvent $event): void {
            $event->getCriteria()->addAssociation('lineItems.product');
        });

        $browser->request('GET', $_SERVER['APP_URL'] . '/widgets/account/order/detail/' . $orderId);
        /** @var StorefrontResponse $response */
        $response = $browser->getResponse();

        /** @var OrderLineItemCollection $orderLineItemCollection */
        $orderLineItemCollection = $response->getData()['orderDetails'];

        foreach ($orderLineItemCollection as $orderLineItemEntity) {
            static::assertNotNull($orderLineItemEntity->getProduct());
        }
'snippetSetId' => $this->getSnippetSetIdForLocale('de-DE'),
                        'url' => 'http://localhost/de',
                    ],
                ],
            ],
            [
                SalesChannelContextService::LANGUAGE_ID => $this->getDeDeLanguageId(),
            ]
        );

        $criteria = new Criteria([self::$categoryId]);
        $criteria->addAssociation('media');

        $category = $this->categoryRepository->search($criteria$salesChannelContextDe->getContext())->getEntities()->get(self::$categoryId);
        static::assertNotNull($category);

        $pages = $this->salesChannelCmsPageLoader->load(
            new Request(),
            new Criteria([self::$category['cmsPage']['id']]),
            $salesChannelContextDe,
            $category->getTranslation('slotConfig')
        );

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