Skip to content

Commit

Permalink
fixed reindex only published article for live
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed Apr 5, 2017
1 parent 657927b commit d5e9fd0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Sulu\Bundle\ArticleBundle\Command;

use Sulu\Component\Content\Document\WorkflowStage;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -39,16 +40,17 @@ public function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$sql2 = 'SELECT * FROM [nt:unstructured] AS a WHERE [jcr:mixinTypes] = "sulu:article"';

$id = 'sulu_article.elastic_search.article_indexer';
if ($input->getOption('live')) {
$id = 'sulu_article.elastic_search.article_live_indexer';
$sql2 .= ' AND [i18n:en-state] = ' . WorkflowStage::PUBLISHED;
}

$indexer = $this->getContainer()->get($id);
$documentManager = $this->getContainer()->get('sulu_document_manager.document_manager');
$query = $documentManager->createQuery(
'SELECT * FROM [nt:unstructured] AS a WHERE [jcr:mixinTypes] = "sulu:article"'
);
$query = $documentManager->createQuery($sql2);

if ($input->getOption('clear')) {
$indexer->clear();
Expand Down

0 comments on commit d5e9fd0

Please sign in to comment.