コード例 #1
0
ファイル: AbstractAction.php プロジェクト: rafaelstz/magento2
 /**
  * Reindex all products to root category
  *
  * @param \Magento\Store\Model\Store $store
  * @return void
  */
 protected function reindexRootCategory(\Magento\Store\Model\Store $store)
 {
     if ($this->isIndexRootCategoryNeeded()) {
         $selects = $this->prepareSelectsByRange($this->getAllProducts($store), 'entity_id', self::RANGE_PRODUCT_STEP);
         foreach ($selects as $select) {
             $this->connection->query($this->connection->insertFromSelect($select, $this->getMainTmpTable(), ['category_id', 'product_id', 'position', 'is_parent', 'store_id', 'visibility'], \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE));
         }
     }
 }
コード例 #2
0
 /**
  * Copy data from source table to destination
  *
  * @param string $sourceTable
  * @param string $destTable
  * @param null|string $where
  * @return void
  */
 protected function _insertFromTable($sourceTable, $destTable, $where = null)
 {
     $sourceColumns = array_keys($this->_connection->describeTable($sourceTable));
     $targetColumns = array_keys($this->_connection->describeTable($destTable));
     $select = $this->_connection->select()->from($sourceTable, $sourceColumns);
     if ($where) {
         $select->where($where);
     }
     $query = $this->_connection->insertFromSelect($select, $destTable, $targetColumns, \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE);
     $this->_connection->query($query);
 }
コード例 #3
0
 /**
  * @inheritdoc
  */
 public function rollbackDocument($documentName)
 {
     $backupTableName = self::BACKUP_DOCUMENT_PREFIX . $documentName;
     if ($this->resourceAdapter->isTableExists($backupTableName)) {
         $this->resourceAdapter->truncateTable($documentName);
         $select = $this->resourceAdapter->select()->from($backupTableName);
         $query = $this->resourceAdapter->insertFromSelect($select, $documentName);
         $this->resourceAdapter->query($query);
         $this->resourceAdapter->dropTable($backupTableName);
     }
 }