progressAdvance example


                        'id' => Uuid::randomHex(),
                        'name' => $group,
                        'options' => $mapped,
                        'sorting_type' => PropertyGroupDefinition::SORTING_TYPE_ALPHANUMERIC,
                        'display_type' => PropertyGroupDefinition::DISPLAY_TYPE_TEXT,
                    ],
                ],
                $context->getContext()
            );

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

        $context->getConsole()->progressFinish();
    }
}
$criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('mail_template_type.mailTemplates.id', null));

        $mailTypeIds = $this->mailTemplateTypeRepository->search($criteria$context->getContext())->getIds();

        $payload = [];
        foreach ($mailTypeIds as $mailTypeId) {
            $payload[] = $this->createSimpleMailTemplate($context$mailTypeId);

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

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

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

    

            }

            $sequences = json_decode((string) json_encode($sequences->jsonSerialize(), \JSON_THROW_ON_ERROR), true, 512, \JSON_THROW_ON_ERROR);

            $sequences = array_map(fn (array $sequence) => array_filter($sequence)$sequences);

            $flow['sequences'] = $sequences;
            $payload[] = $flow;

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

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

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

    

        $criteria = $this->createCriteria();

        do {
            $result = $this->mediaRepository->search($criteria$context);

            /** @var MediaCollection $medias */
            $medias = $result->getEntities();
            foreach ($medias as $media) {
                $this->detectMediaType($context$media);
            }
            $this->io->progressAdvance($result->count());
            $criteria->setOffset($criteria->getOffset() + $this->batchSize);
        } while ($result->getTotal() > $this->batchSize);
    }

    private function detectMediaType(Context $context, MediaEntity $media): void
    {
        if (!$media->hasFile()) {
            return;
        }

        $file = new MediaFile(
            


    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);
        

                $this->fileNameProvider->provide(
                    pathinfo($file, \PATHINFO_FILENAME),
                    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
    {
if ($i % 40 === 0) {
                $combination = $this->faker->randomElement($combinations);
                $product = [...$product, ...$this->buildVariants($combination$prices$taxes)];
            } elseif ($i % 20 === 0) {
                $product = [...$product, ...$this->buildDownloads($downloadMediaIds$instantDeliveryId)];
            }

            $payload[] = $product;

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

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

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

    
$collection->sync();

        $this->io->writeln('migrate Migrations');

        $migrationCount = $this->getMigrationsCount($collection$until$limit);
        $this->io->progressStart($migrationCount);
        $migratedCounter = 0;

        try {
            foreach ($this->getMigrationGenerator($collection$until$limit) as $_return) {
                $this->io->progressAdvance();
                ++$migratedCounter;
            }
        } catch (\Exception $e) {
            $this->finishProgress($migratedCounter$migrationCount);

            throw new MigrateException($e->getMessage() . \PHP_EOL . 'Trace: ' . \PHP_EOL . $e->getTraceAsString()$e);
        }

        $this->finishProgress($migratedCounter$migrationCount);
        $this->io->writeln(sprintf('all migrations for identifier: "%s" executed', $identifier));

        
for ($i = 0; $i < $numberOfItems; ++$i) {
            $payload[] = [
                'id' => Uuid::randomHex(),
                '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();
    }
}
private function createMailHeaderFooter(DemodataContext $context, int $numberOfItems): void
    {
        $context->getConsole()->progressStart($numberOfItems);

        $payload = [];
        for ($i = 0; $i < $numberOfItems; ++$i) {
            $mailHeaderFooter = $this->prepareHeaderFooterData($context);

            $payload[] = $mailHeaderFooter;

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

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

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

    
'username' => $context->getFaker()->format('userName'),
                'email' => $id . $context->getFaker()->format('safeEmail'),
                'password' => 'shopware',
                'localeId' => $this->getLocaleId($context->getContext()),
            ];

            $payload[] = $user;

            if (\count($payload) >= 100) {
                $this->writer->upsert($this->userDefinition, $payload$writeContext);

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

                $payload = [];
            }
        }

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

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

        
'externalUser' => $context->getFaker()->name(),
                'externalEmail' => $context->getFaker()->email(),
                'title' => $context->getFaker()->sentence(),
                'content' => $context->getFaker()->text(),
                'points' => $context->getFaker()->randomElement($points),
                'status' => (bool) random_int(0, 1),
            ];

            if (\count($payload) >= 100) {
                $this->writer->upsert($this->productReviewDefinition, $payload$writeContext);

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

                $payload = [];
            }
        }

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

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

        
'defaultBillingAddressId' => $addresses[array_rand($addresses)]['id'],
                'defaultShippingAddressId' => $addresses[array_rand($addresses)]['id'],
                'addresses' => $addresses,
                'tags' => $this->getTags($tags),
            ];

            $payload[] = $customer;

            if (\count($payload) >= 100) {
                $this->writer->upsert($this->customerDefinition, $payload$writeContext);

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

                $payload = [];
            }
        }

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

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

        
try {
                    if ($this->thumbnailService->updateThumbnails($media$context$this->isStrict) > 0) {
                        ++$generated;
                    } else {
                        ++$skipped;
                    }
                } catch (\Throwable $e) {
                    ++$errored;
                    $errors[] = [sprintf('Cannot process file %s (id: %s) due error: %s', $media->getFileName()$media->getId()$e->getMessage())];
                }
            }
            $this->io->progressAdvance($result->count());
        }

        return [
            'generated' => $generated,
            'skipped' => $skipped,
            'errored' => $errored,
            'errors' => $errors,
        ];
    }

    private function createCriteria(): Criteria
    {
$cart = $this->cartCalculator->calculate($cart$salesChannelContext);
            $tempOrder = $this->orderConverter->convertToOrder($cart$salesChannelContextnew OrderConversionContext());

            $tempOrder['orderDateTime'] = (new \DateTime())->modify('-' . random_int(0, 30) . ' days')->format(Defaults::STORAGE_DATE_TIME_FORMAT);
            $tempOrder['tags'] = $this->getTags($tags);

            $orders[] = $tempOrder;

            if (\count($orders) >= 20) {
                $this->writer->upsert($this->orderDefinition, $orders$writeContext);
                $context->getConsole()->progressAdvance(\count($orders));
                $orders = [];
            }
        }

        if (!empty($orders)) {
            $this->writer->upsert($this->orderDefinition, $orders$writeContext);
        }

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

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