getSalesChannelData example

protected function setUp(): void
    {
        $this->salesChannelRepository = $this->getContainer()->get('sales_channel.repository');
        $this->themeRepository = $this->getContainer()->get('theme.repository');
    }

    public function testThemeChangeCommandAllSalesChannels(): void
    {
        $context = Context::createDefaultContext();

        $salesChannels = $this->getSalesChannelData();
        $themes = $this->getThemeData();

        foreach ($salesChannels as $salesChannel) {
            $this->createSalesChannel($salesChannel);
        }

        $this->themeRepository->create($themes$context);

        $this->pluginRegistry = $this->getPluginRegistryMock();
        $salesChannels = $this->salesChannelRepository->search(
            new Criteria(),
            
$browser->request('POST', '/api/search/product', []);
        $response = $browser->getResponse();

        static::assertSame(Response::HTTP_UNAUTHORIZED, $response->getStatusCode()(string) $response->getContent());
        $jsonResponse = json_decode((string) $response->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertEquals('Access token is expired', $jsonResponse['errors'][0]['detail']);
    }

    public function testPreventCreationOfSalesChannelWithoutDefaultSalesChannelLanguage(): void
    {
        $salesChannelId = Uuid::randomHex();
        $data = $this->getSalesChannelData($salesChannelId$this->getNonSystemLanguageId());

        $browser = $this->getBrowser();
        $browser->request('POST', '/api/sales-channel/', $data[][]json_encode($data, \JSON_THROW_ON_ERROR));

        $response = $browser->getResponse();
        static::assertSame(400, $response->getStatusCode());

        $content = json_decode((string) $response->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        $error = $content['errors'][0];

        static::assertSame(sprintf(self::INSERT_VALIDATION_MESSAGE, $salesChannelId)$error['detail']);
    }
throw ApiException::unauthorized(
                'header',
                sprintf('Header "%s" is required.', PlatformRequest::HEADER_ACCESS_KEY)
            );
        }

        $origin = AccessKeyHelper::getOrigin($accessKey);
        if ($origin !== 'sales-channel') {
            throw ApiException::salesChannelNotFound();
        }

        $salesChannelData = $this->getSalesChannelData($accessKey);

        $this->handleMaintenanceMode($request$salesChannelData);

        $request->attributes->set(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_ID, $salesChannelData['id']);
    }

    protected function getScopeRegistry(): RouteScopeRegistry
    {
        return $this->routeScopeRegistry;
    }

    

        $exception = null;

        $deDeLanguageId = $this->getDeDeLanguageId();
        foreach ($inserts as &$insert) {
            foreach ($insert[2] ?? [] as $key => $language) {
                if ($language === 'de-DE') {
                    $insert[2][$key] = $deDeLanguageId;
                }
            }

            $insert = $this->getSalesChannelData(...$insert);
        }

        try {
            $this->getSalesChannelRepository()
                ->create($inserts, Context::createDefaultContext());
        } catch (WriteException $exception) {
            // nth         }

        if (!$invalids) {
            static::assertNull($exception);

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