Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace AppBundle\Command;
- use AppBundle\Entity\User;
- use AppBundle\Services\ElasticSearchService;
- use AppBundle\Services\TaxonomyManager;
- use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Output\Output;
- use Symfony\Component\Console\Output\OutputInterface;
- use League\Csv\Reader;
- use League\Csv\Statement;
- class BuildProductIndexCommand extends ContainerAwareCommand
- {
- protected function configure()
- {
- $this
- ->setName('index:products')
- ;
- }
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- define('tradeSubdomain', 'hagebau');
- $container = $this->getContainer();
- $output->writeln('Building index...');
- /** @var TaxonomyManager $taxonomyManager */
- $taxonomyManager = $container->get('manager.taxonomy');
- /** @var ElasticSearchService $elasticSearchService */
- $elasticSearchService = $container->get('service.elastic_search');
- $products = $taxonomyManager->findAllTaxonomyItems('products');
- foreach ($products as $product) {
- if ((String) $product->lookup('root_product') != '') {
- continue;
- }
- if ((String) $product->lookup('category') == '') {
- continue;
- }
- $elasticSearchService->buildProductIndex($product);
- $output->writeln(sprintf('Product with id: %s has been indexed.', $product->getId()));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement