/** * Run full reindex only when needed * * @return Enterprise_CatalogSearch_Model_Index_Action_Fulltext_Refresh * * @throws Enterprise_Index_Model_Action_Exception */ public function execute() { if (Mage::helper('smile_elasticsearch')->isActiveEngine() == false) { parent::execute(); } else { $this->_getLastVersionId(); $this->_metadata->setInProgressStatus()->save(); $engine = Mage::helper('catalogsearch')->getEngine(); $index = $engine->getCurrentIndex(); $index->prepareNewIndex(); foreach ($index->getAllMappings() as $mapping) { $mapping->rebuildIndex(); } $index->installNewIndex(); $this->_updateMetadata(); $this->_app->dispatchEvent('after_reindex_process_catalogsearch_index', array()); } return $this; }