Skip to content

Commit

Permalink
Merge pull request #2 from fprause/patch-1
Browse files Browse the repository at this point in the history
- ✨ Now updates collection in all Locales
  • Loading branch information
jsblair9 authored May 29, 2019
2 parents 4572514 + 6c1c646 commit 85ad9a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions UpdateCollectionSearch/UpdateCollectionSearchListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Statamic\Addons\UpdateCollectionSearch;

use Statamic\API\Config;
use Statamic\Data\Entries\Entry;
use Statamic\Extend\Listener;
use Statamic\API\Search;
Expand All @@ -21,7 +22,9 @@ public function handleEntrySaved(Entry $entry)

if ($this->shouldUpdateCollection($collection_name)) {
$index = 'collections/' . $collection_name;
Search::update($index);
foreach (Config::getLocales() as $locale) {
Search::in($index, $locale)->update();
}
}
}

Expand All @@ -36,4 +39,4 @@ private function shouldUpdateCollection($collection_name)
{
return collect($this->getConfig('collection_to_index'))->contains($collection_name);
}
}
}

0 comments on commit 85ad9a4

Please sign in to comment.