Skip to content

Commit

Permalink
MAGETWO-64518: \Magento\CatalogRule\Model\Indexer\IndexBuilder method…
Browse files Browse the repository at this point in the history
… "doReindexFull()" causes temporary missing sale prices
  • Loading branch information
Stanislav Idolov committed Jun 21, 2017
1 parent 0e95567 commit 944de8d
Show file tree
Hide file tree
Showing 26 changed files with 1,013 additions and 357 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function __construct(
public function execute()
{
$this->reindex();
$this->activeTableSwitcher->switchTable($this->connection, $this->getMainTable());
$this->activeTableSwitcher->switchTable($this->connection, [$this->getMainTable()]);
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function execute($ids = null)
$this->syncData($indexer, $mainTable);
}
}
$this->activeTableSwitcher->switchTable($indexer->getConnection(), $indexer->getMainTable());
$this->activeTableSwitcher->switchTable($indexer->getConnection(), [$indexer->getMainTable()]);
}
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function execute($ids = null)
}
$this->activeTableSwitcher->switchTable(
$this->_defaultIndexerResource->getConnection(),
$this->_defaultIndexerResource->getMainTable()
[$this->_defaultIndexerResource->getMainTable()]
);
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ class ActiveTableSwitcher
* Switch index tables from replica to active.
*
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
* @param string $tableName
* @param array $tableNames
* @return void
*/
public function switchTable(\Magento\Framework\DB\Adapter\AdapterInterface $connection, $tableName)
public function switchTable(\Magento\Framework\DB\Adapter\AdapterInterface $connection, array $tableNames)
{
$outdatedTableName = $tableName . $this->outdatedTableSuffix;
$replicaTableName = $tableName . $this->additionalTableSuffix;
$toRename = [];
foreach ($tableNames as $tableName) {
$outdatedTableName = $tableName . $this->outdatedTableSuffix;
$replicaTableName = $tableName . $this->additionalTableSuffix;

$connection->renameTablesBatch(
[
$renameBatch = [
[
'oldName' => $tableName,
'newName' => $outdatedTableName
Expand All @@ -42,8 +43,13 @@ public function switchTable(\Magento\Framework\DB\Adapter\AdapterInterface $conn
'oldName' => $outdatedTableName,
'newName' => $replicaTableName
]
]
);
];
$toRename = array_merge($toRename, $renameBatch);
}

if (!empty($toRename)) {
$connection->renameTablesBatch($toRename);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testSwitch()
]
);

$this->model->switchTable($connectionMock, $tableName);
$this->model->switchTable($connectionMock, [$tableName]);
}

public function testGetAdditionalTableName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function execute($ids = null)
}
}
}
$this->activeTableSwitcher->switchTable($indexer->getConnection(), $indexer->getMainTable());
$this->activeTableSwitcher->switchTable($indexer->getConnection(), [$indexer->getMainTable()]);
} catch (\Exception $e) {
throw new LocalizedException(__($e->getMessage()), $e);
}
Expand Down
Loading

0 comments on commit 944de8d

Please sign in to comment.