diff --git a/src/Extensions/AlgoliaObjectExtension.php b/src/Extensions/AlgoliaObjectExtension.php index 52dc8b0..e13ce90 100644 --- a/src/Extensions/AlgoliaObjectExtension.php +++ b/src/Extensions/AlgoliaObjectExtension.php @@ -23,6 +23,11 @@ class AlgoliaObjectExtension extends DataExtension { use Configurable; + /** + * @var boolean + */ + private $ranSync = false; + /** * @config * @@ -73,8 +78,18 @@ public function updateSettingsFields(FieldList $fields) */ public function requireDefaultRecords() { + if ($this->ranSync) { + return false; + } + + $this->ranSync = true; $algolia = Injector::inst()->create(AlgoliaService::class); - $algolia->syncSettings(); + + try { + $algolia->syncSettings(); + } catch (Exception $e) { + DB::alteration_message($e->getMessage(), 'error'); + } } /**