Skip to content

Commit

Permalink
Trigger Categories Fulltext reindex on install.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainruaud committed Sep 30, 2016
1 parent bc14c44 commit 72e0a6e
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/module-elasticsuite-catalog/Setup/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Eav\Setup\EavSetup;
use Magento\Framework\Indexer\IndexerInterfaceFactory;

/**
* Catalog installer
Expand Down Expand Up @@ -52,16 +53,23 @@ class InstallData implements InstallDataInterface
*/
private $metadataPool;

/**
* @var \Smile\ElasticsuiteCatalog\Setup\IndexerInterfaceFactory
*/
private $indexerFactory;

/**
* Class Constructor
*
* @param EavSetupFactory $eavSetupFactory Eav setup factory.
* @param MetadataPool $metadataPool Metadata Pool.
* @param EavSetupFactory $eavSetupFactory Eav setup factory.
* @param MetadataPool $metadataPool Metadata Pool.
* @param IndexerInterfaceFactory $indexerFactory Indexer Factory.
*/
public function __construct(EavSetupFactory $eavSetupFactory, MetadataPool $metadataPool)
public function __construct(EavSetupFactory $eavSetupFactory, MetadataPool $metadataPool, IndexerInterfaceFactory $indexerFactory)
{
$this->metadataPool = $metadataPool;
$this->eavSetupFactory = $eavSetupFactory;
$this->indexerFactory = $indexerFactory;
}

/**
Expand All @@ -84,6 +92,8 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
$this->updateCategoryIsAnchorAttribute();
$this->updateDefaultValuesForNameAttributes();

$this->getIndexer('elasticsuite_categories_fulltext')->reindexAll();

$setup->endSetup();
}

Expand Down Expand Up @@ -209,4 +219,16 @@ private function updateDefaultValuesForNameAttributes()
}
}
}

/**
* Retrieve an indexer by its Id
*
* @param string $indexerId The indexer Id
*
* @return \Magento\Framework\Indexer\IndexerInterface
*/
private function getIndexer($indexerId)
{
return $this->indexerFactory->create()->load($indexerId);
}
}

0 comments on commit 72e0a6e

Please sign in to comment.