Skip to content

Instantly share code, notes, and snippets.

@nicanaca0
Created July 5, 2017 16:08
Show Gist options
  • Save nicanaca0/d219a1b7801d730dec2e56a46ab1b540 to your computer and use it in GitHub Desktop.
Save nicanaca0/d219a1b7801d730dec2e56a46ab1b540 to your computer and use it in GitHub Desktop.
Simple command to remove ALL products (1.0.0-beta.2)
<?php
namespace AppBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CleanUpCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('clean:up')
->setDescription('Clean up products and categories - Bulk Remover')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$manager = $this->getContainer()->get('sylius.manager.product');
$repo = $this->getContainer()->get('sylius.repository.product');
foreach ($repo->findAll() as $product) {
$manager->remove($product);
}
$manager->flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment