createProductStream example

return $repository->search(new Criteria()$this->context)->first();
    }

    private function getSalesChannelDomainId(): string
    {
        return $this->getSalesChannelDomain()->getId();
    }

    private function createTestEntity(): string
    {
        $this->createProductStream();

        $id = Uuid::randomHex();
        $this->repository->upsert([
            [
                'id' => $id,
                'fileName' => 'Testexport.csv',
                'accessKey' => Uuid::randomHex(),
                'encoding' => ProductExportEntity::ENCODING_UTF8,
                'fileFormat' => ProductExportEntity::FILE_FORMAT_CSV,
                'interval' => 0,
                'headerTemplate' => 'name,url',
                
return $repository->search($criteria$this->context)->first();
    }

    private function getSalesChannelDomainId(): string
    {
        return $this->getSalesChannelDomain()->getId();
    }

    private function createTestEntity(): string
    {
        $this->createProductStream();

        $id = Uuid::randomHex();
        $this->repository->upsert([
            [
                'id' => $id,
                'fileName' => 'Testexport.csv',
                'accessKey' => Uuid::randomHex(),
                'encoding' => ProductExportEntity::ENCODING_UTF8,
                'fileFormat' => ProductExportEntity::FILE_FORMAT_CSV,
                'interval' => 0,
                'headerTemplate' => 'name,url',
                
use IntegrationTestBehaviour;

    private Context $context;

    protected function setUp(): void
    {
        $this->context = Context::createDefaultContext();
    }

    public function testValidate(): void
    {
        $this->createProductStream();

        $url = '/api/_action/product-export/validate';

        $content = json_encode([
            'salesChannelId' => $this->getSalesChannelDomain()->getSalesChannelId(),
            'salesChannelDomainId' => $this->getSalesChannelDomainId(),
            'productStreamId' => '137b079935714281ba80b40f83f8d7eb',
            'headerTemplate' => '',
            'bodyTemplate' => '{{ product.name }}',
            'footerTemplate' => '',
            'includeVariants' => false,
            
$this->context = Context::createDefaultContext();
        $this->fileSystem = $this->getContainer()->get('shopware.filesystem.private');
    }

    /** * @group quarantined */
    public function testRun(): void
    {
        // Add a second storefront sales channel, to check if all sales channels will be recognized for the product export         $this->createSecondStorefrontSalesChannel();
        $this->createProductStream();

        // only get seconds, not microseconds, for better comparison to DB         /** @var \DateTime $previousGeneratedAt */
        $previousGeneratedAt = \DateTime::createFromFormat('U', (string) time());
        $exportId = $this->createTestEntity($previousGeneratedAt);
        $this->clearQueue();
        $this->getTaskHandler()->run();

        $url = '/api/_action/message-queue/consume';
        $client = $this->getBrowser();
        $client->request('POST', $url['receiver' => 'async']);

        
return $repository->search(new Criteria()$this->context)->first();
    }

    private function getSalesChannelDomainId(): string
    {
        return $this->getSalesChannelDomain()->getId();
    }

    private function createTestEntity(array $override = []): string
    {
        $this->createProductStream();

        $id = Uuid::randomHex();
        $this->repository->upsert([
            array_merge([
                'id' => $id,
                'fileName' => 'Testexport.csv',
                'accessKey' => Uuid::randomHex(),
                'encoding' => ProductExportEntity::ENCODING_UTF8,
                'fileFormat' => ProductExportEntity::FILE_FORMAT_CSV,
                'interval' => 0,
                'headerTemplate' => 'name,stock',
                

    private $repository;

    private Context $context;

    protected function setUp(): void
    {
        $this->repository = $this->getContainer()->get('product_export.repository');
        $this->context = Context::createDefaultContext();

        $this->createProductStream();
    }

    public function testCreateEntity(): void
    {
        $id = Uuid::randomHex();
        $this->repository->upsert([
            [
                'id' => $id,
                'fileName' => 'Testexport',
                'accessKey' => Uuid::randomHex(),
                'encoding' => ProductExportEntity::ENCODING_UTF8,
                
return $repository->search(new Criteria()$this->context)->first();
    }

    private function getSalesChannelDomainId(): string
    {
        return $this->getSalesChannelDomain()->getId();
    }

    private function createTestEntity(): string
    {
        $this->createProductStream();

        $id = Uuid::randomHex();
        $this->repository->upsert([
            [
                'id' => $id,
                'fileName' => 'Testexport.xml',
                'accessKey' => Uuid::randomHex(),
                'encoding' => ProductExportEntity::ENCODING_UTF8,
                'fileFormat' => ProductExportEntity::FILE_FORMAT_XML,
                'interval' => 0,
                'headerTemplate' => '<?xml version="1.0"?><export>',
                
public function testLoad(): void
    {
        $productId = Uuid::randomHex();

        $productData = $this->getProductData($productId);
        $productData['crossSellings'] = [[
            'name' => 'Test Cross Selling',
            'sortBy' => ProductCrossSellingDefinition::SORT_BY_PRICE,
            'sortDirection' => FieldSorting::ASCENDING,
            'active' => true,
            'limit' => 3,
            'productStreamId' => $this->createProductStream(),
        ]];

        $this->productRepository->create([$productData]$this->salesChannelContext->getContext());

        $result = $this->route->load($productIdnew Request()$this->salesChannelContext, new Criteria())
            ->getResult();

        static::assertEquals(1, $result->count());

        $element = $result->first();
        static::assertNotNull($element);
        
$repository = $this->getContainer()->get('sales_channel_domain.repository');

        /** @var SalesChannelDomainEntity $salesChannelDomain */
        $salesChannelDomain = $repository->search(new Criteria()$this->context)->first();
        static::assertNotNull($salesChannelDomain);

        return $salesChannelDomain;
    }

    private function createCsvExport(string $encoding, string $salesChannelId, string $salesChannelDomainId): ProductExportEntity
    {
        $this->createProductStream($salesChannelId);

        $productExportId = Uuid::randomHex();

        $this->repository->upsert([
            [
                'id' => $productExportId,
                'fileName' => 'Testexport',
                'accessKey' => Uuid::randomHex(),
                'encoding' => $encoding,
                'fileFormat' => ProductExportEntity::FILE_FORMAT_CSV,
                'interval' => 0,
                
Home | Imprint | This part of the site doesn't use cookies.