Created
July 5, 2017 16:08
-
-
Save nicanaca0/d219a1b7801d730dec2e56a46ab1b540 to your computer and use it in GitHub Desktop.
Simple command to remove ALL products (1.0.0-beta.2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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