/**
  * Refresh the custom products position index : just rebuild data from this data provider
  *
  * @return Smile_VirtualCategories_Model_Index_Action_VirtualCategories_Product_Position_Refresh
  *
  * @throws Enterprise_Index_Model_Action_Exception
  */
 public function execute()
 {
     if (!Mage::helper('smile_elasticsearch')->isActiveEngine() == false) {
         $this->_metadata->setInProgressStatus()->save();
         // Let the index process all data
         $this->_indexer->reindexAll();
         if ($this->_metadata->getStatus() == Enterprise_Mview_Model_Metadata::STATUS_IN_PROGRESS) {
             $this->_metadata->setValidStatus()->save();
         }
     }
     return $this;
 }
 /**
  * Set changelog valid and update version id into metedata
  *
  * @return Enterprise_Index_Model_Action_Abstract
  */
 protected function _updateMetadata()
 {
     if ($this->_metadata->getStatus() == Enterprise_Mview_Model_Metadata::STATUS_IN_PROGRESS) {
         $this->_metadata->setValidStatus();
     }
     $this->_metadata->setVersionId($this->_getLastVersionId())->save();
     return $this;
 }
 /**
  * Set changelog valid
  *
  * @return Enterprise_Index_Model_Action_Abstract
  */
 protected function _setChangelogValid()
 {
     $this->_metadata->load($this->_metadata->getId());
     if ($this->_metadata->getStatus() == Enterprise_Mview_Model_Metadata::STATUS_IN_PROGRESS) {
         $this->_metadata->setValidStatus();
     }
     $this->_metadata->setVersionId($this->_getCurrentVersionId())->save();
     return $this;
 }
 /**
  * Refresh materialized view
  *
  * @return Enterprise_Mview_Model_Action_Mview_Refresh
  * @throws Exception
  */
 public function execute()
 {
     try {
         $insert = $this->_connection->insertFromSelect($this->_connection->select()->from($this->_metadata->getViewName()), $this->_metadata->getTableName());
         $this->_connection->delete($this->_metadata->getTableName());
         $this->_connection->query($insert);
         $this->_metadata->setValidStatus()->setVersionId($this->_selectLastVersionId())->save();
     } catch (Exception $e) {
         $this->_metadata->setInvalidStatus()->save();
         throw $e;
     }
     return $this;
 }
 /**
  * Create view and mview table
  * 1) Create view;
  * 2) Create table;
  * 3) Update view name and status in metadata.
  *
  * @return Enterprise_Mview_Model_Action_Mview_Create
  * @throws Exception
  */
 public function execute()
 {
     try {
         if (!$this->_view->isExists()) {
             $this->_view->createFromSource($this->_select);
         }
         if (!$this->_table->isExists()) {
             $select = $this->_connection->select()->from($this->_view->getObjectName());
             $this->_table->createFromSource($select);
         }
         $this->_metadata->setViewName($this->_view->getObjectName());
         $this->_metadata->setValidStatus();
         $this->_metadata->save();
     } catch (Exception $e) {
         $this->_view->drop();
         $this->_table->drop();
         throw $e;
     }
     return $this;
 }