progressFinish example

/** * @param RepositoryIterator<MediaCollection> $mediaIterator */
    private function generateSynchronous(RepositoryIterator $mediaIterator, Context $context): void
    {
        $totalMediaCount = $mediaIterator->getTotal();
        $this->io->comment(sprintf('Generating Thumbnails for %d files. This may take some time...', $totalMediaCount));
        $this->io->progressStart($totalMediaCount);

        $result = $this->generateThumbnails($mediaIterator$context);

        $this->io->progressFinish();
        $this->io->table(
            ['Action', 'Number of Media Entities'],
            [
                ['Generated', $result['generated']],
                ['Skipped', $result['skipped']],
                ['Errors', $result['errored']],
            ]
        );

        if (is_countable($result['errors']) ? \count($result['errors']) : 0) {
            if ($this->io->isVerbose()) {
                

        $this->io = new ShopwareStyle($input$output);

        $context = Context::createDefaultContext();
        $this->batchSize = $this->validateBatchSize($input);

        $this->io->comment('Starting to generate MediaTypes. This may take some time...');
        $this->io->progressStart($this->getMediaCount($context));

        $this->detectMediaTypes($context);

        $this->io->progressFinish();

        return self::SUCCESS;
    }

    private function validateBatchSize(InputInterface $input): int
    {
        $batchSize = $input->getOption('batch-size');
        if ($batchSize === null) {
            return 100;
        }

        
'name' => $context->getFaker()->format('productName') . ' Tag',
            ];
        }

        $writeContext = WriteContext::createFromContext($context->getContext());

        foreach (array_chunk($payload, 100) as $chunk) {
            $this->writer->upsert($this->tagDefinition, $chunk$writeContext);
            $context->getConsole()->progressAdvance(\count($chunk));
        }

        $context->getConsole()->progressFinish();
    }
}
$payload = [];
            }
        }

        if (!empty($payload)) {
            $this->writer->upsert($this->userDefinition, $payload$writeContext);

            $context->getConsole()->progressAdvance(\count($payload));
        }

        $context->getConsole()->progressFinish();
    }

    private function getRandomTitle(): string
    {
        $titles = ['', 'Dr.', 'Dr. med.', 'Prof.', 'Prof. Dr.'];

        return $titles[array_rand($titles)];
    }

    private function getLocaleId(Context $context): string
    {
        
pathinfo($file, \PATHINFO_EXTENSION),
                    $mediaId,
                    $context->getContext()
                ),
                $mediaId,
                $context->getContext()
            );

            $context->getConsole()->progressAdvance(1);
        }

        $context->getConsole()->progressFinish();
    }

    /** * @param list<string> $tags * * @return list<array{id: string}> */
    private function getTags(array $tags): array
    {
        $tagAssignments = [];

        
public function generate(int $numberOfItems, DemodataContext $context, array $options = []): void
    {
        $console = $context->getConsole();
        $console->comment('Generate attribute sets: ' . $numberOfItems);
        $console->progressStart($numberOfItems);

        for ($i = 0; $i < $numberOfItems; ++$i) {
            $this->generateCustomFieldSet($options$context);

            $console->progressAdvance(1);
        }
        $console->progressFinish();

        $relations = $options['relations'];
        $sum = (int) array_sum($relations);
        if ($sum <= 0) {
            return;
        }

        $console->comment('Set attributes for entities: ' . $sum);
        $console->progressStart($sum);
        foreach ($relations as $relation => $count) {
            if (!$count || $count < 1) {
                
if (\count($payload) >= 20) {
                $this->io->progressAdvance(\count($payload));
                $this->write($payload$context);
                $payload = [];
            }
        }

        if (!empty($payload)) {
            $this->write($payload$context);
        }

        $this->io->progressFinish();
    }

    /** * @param array<string, list<string>> $properties * * @return array<array<string, mixed>> */
    private function buildCombinations(array $properties): array
    {
        $properties = $this->faker->randomElements($propertiesrandom_int(min(\count($properties), 1)min(\count($properties), 4)));

        
$payload[] = [
                'id' => Uuid::randomHex(),
                'name' => $faker->format('productName'),
                'description' => $faker->text(),
                'filters' => [['type' => 'multi', 'operator' => 'OR', 'queries' => $filters]],
            ];
        }

        $this->writer->insert($this->productStreamDefinition, $payload, WriteContext::createFromContext($context->getContext()));

        $context->getConsole()->progressFinish();
    }
}


        $console = $context->getConsole();
        $console->progressStart($numberOfItems);

        foreach ($payload as $cat) {
            $this->categoryRepository->create([$cat]$context->getContext());

            $context->getConsole()->progressAdvance();
        }

        $context->getConsole()->progressFinish();
    }

    /** * @param list<string> $pageIds * @param list<string> $tags * * @return array<string, mixed> */
    private function createCategory(DemodataContext $context, array $pageIds, array $tags, string $parentId, ?string $afterId, int $max, int $current): array
    {
        $id = Uuid::randomHex();

        
if (\count($payload) >= 20) {
                $this->io->progressAdvance(\count($payload));
                $this->write($payload$context);
                $payload = [];
            }
        }

        if (!empty($payload)) {
            $this->write($payload$context);
        }

        $this->io->progressFinish();
    }

    private function buildRandomSequence(FlowSequenceEntity $parent, bool $trueCase = true): FlowSequenceEntity
    {
        if ($this->faker->boolean()) {
            return $this->buildIfSequence($parent$trueCase);
        }

        return $this->buildActionSequence($parent$trueCase);
    }

    
if (\count($payload) >= 10) {
                $context->getConsole()->progressAdvance(\count($payload));
                $this->write($payload$context);
                $payload = [];
            }
        }

        if (!empty($payload)) {
            $this->write($payload$context);
        }

        $context->getConsole()->progressFinish();
    }

    /** * @param list<array<string, mixed>> $payload */
    private function write(array $payload, DemodataContext $context): void
    {
        $writeContext = WriteContext::createFromContext($context->getContext());

        $this->writer->upsert($this->mailTemplateDefinition, $payload$writeContext);
    }

    
if (\count($payload) >= 20) {
                $this->io->progressAdvance(\count($payload));
                $this->write($payload$context);
                $payload = [];
            }
        }

        if (!empty($payload)) {
            $this->write($payload$context);
        }

        $this->io->progressFinish();
    }

    /** * @param list<array<string, mixed>> $payload */
    private function write(array $payload, Context $context): void
    {
        $context->addState(EntityIndexerRegistry::DISABLE_INDEXING);

        $this->registry->getRepository('promotion')->create($payload$context);

        
$this->shopwareVersion,
                MigrationCollectionLoader::VERSION_SELECTION_ALL
            );
        }

        return $this->loader->collect($identifier);
    }

    private function finishProgress(int $migrated, int $total): void
    {
        if ($migrated === $total) {
            $this->io->progressFinish();
        }

        $this->io->table(
            ['Action', 'Number of migrations'],
            [
                ['Migrated', $migrated . ' out of ' . $total],
            ]
        );
    }

    private function runMigrationForIdentifier(InputInterface $input, string $identifier, int $limit, ?int $until): int
    {
'options' => $mapped,
                        'sorting_type' => PropertyGroupDefinition::SORTING_TYPE_ALPHANUMERIC,
                        'display_type' => PropertyGroupDefinition::DISPLAY_TYPE_TEXT,
                    ],
                ],
                $context->getContext()
            );

            $context->getConsole()->progressAdvance(1);
        }

        $context->getConsole()->progressFinish();
    }
}
if (!empty($payload)) {
            $this->writer->upsert($this->productReviewDefinition, $payload$writeContext);

            $context->getConsole()->progressAdvance(\count($payload));
        }

        foreach ($customerIdsWithReviews as $customerId => $_) {
            $this->productReviewCountService->updateReviewCountForCustomer(Uuid::fromHexToBytes($customerId));
        }

        $context->getConsole()->progressFinish();
    }

    /** * @return array<string> */
    private function getCustomerIds(): array
    {
        $sql = 'SELECT LOWER(HEX(id)) as id FROM customer LIMIT 200';

        $customerIds = $this->connection->fetchAllAssociative($sql);

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