You can show the progress bar in the command this way:
use Symfony\Component\Console\Helper\ProgressBar;
$progress = new ProgressBar($output, 50);
$progress->start();
$i = 0;
while ($i++ < 50) {
$progress->advance();
}
$progress->finish()
But what if you only have a service call on the command:
$this->getContainer()->get('update.product.countries')->update();
public function update()
{
$validCountryCodes = $this->countryRepository->findAll();
$products = $this->productRepository->findWithInvalidCountryCode($validCountryCodes);
foreach ($products as $product) {
...
}
}
Is there any way to output progress in a foreach service loop just like in a command file?
source
share