Skip to content

Commit

Permalink
[impr-OpenMage#184] Add option --reindexallrequired to shell/indexe…
Browse files Browse the repository at this point in the history
…r.php

The new option only rebuilds indices that actually require a rebuild.

http://magento.stackexchange.com/questions/3028/permanent-solution-for-the-common-indexing-issue
  • Loading branch information
seansan authored and edannenberg committed Apr 1, 2019
1 parent 0f041e5 commit 0abb5d9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shell/indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function run()
echo $e . "\n";
}
}
} else if ($this->getArg('reindex') || $this->getArg('reindexall')) {
} else if ($this->getArg('reindex') || $this->getArg('reindexall') || $this->getArg('reindexallrequired')) {
if ($this->getArg('reindex')) {
$processes = $this->_parseIndexerString($this->getArg('reindex'));
} else {
Expand All @@ -162,6 +162,10 @@ public function run()
try {
Mage::dispatchEvent('shell_reindex_init_process');
foreach ($processes as $process) {
//reindex only if required
if( $this->getArg('reindexallrequired') && $process->getStatus() == Mage_Index_Model_Process::STATUS_PENDING ) {
continue;
}
/* @var $process Mage_Index_Model_Process */
try {
$startTime = microtime(true);
Expand Down Expand Up @@ -204,6 +208,7 @@ public function usageHelp()
--reindex <indexer> Reindex Data
info Show allowed indexers
reindexall Reindex Data by all indexers
reindexallrequired Reindex Data only if required by all indexers
help This help
<indexer> Comma separated indexer codes or value "all" for all indexers
Expand Down

0 comments on commit 0abb5d9

Please sign in to comment.