@@ -62,20 +62,26 @@ public function __construct(
62
62
*/
63
63
public function execute (Observer $ observer )
64
64
{
65
- $ storeIds = array_keys ($ this ->storeManager ->getStores ());
66
- foreach ($ storeIds as $ storeId ) {
67
- $ indexName = $ this ->helper ->getIndexName ($ this ->productHelper ->getIndexNameSuffix (), $ storeId );
68
- $ currentSettings = $ this ->algoliaHelper ->getSettings ($ indexName );
69
- if (array_key_exists ('replicas ' , $ currentSettings )) {
70
- $ this ->algoliaHelper ->setSettings ($ indexName , ['replicas ' => []]);
71
- $ setReplicasTaskId = $ this ->algoliaHelper ->getLastTaskId ();
72
- $ this ->algoliaHelper ->waitLastTask ($ indexName , $ setReplicasTaskId );
73
- if (count ($ currentSettings ['replicas ' ]) > 0 ) {
74
- foreach ($ currentSettings ['replicas ' ] as $ replicaIndex ) {
75
- $ this ->algoliaHelper ->deleteIndex ($ replicaIndex );
65
+ try {
66
+ $ storeIds = array_keys ($ this ->storeManager ->getStores ());
67
+ foreach ($ storeIds as $ storeId ) {
68
+ $ indexName = $ this ->helper ->getIndexName ($ this ->productHelper ->getIndexNameSuffix (), $ storeId );
69
+ $ currentSettings = $ this ->algoliaHelper ->getSettings ($ indexName );
70
+ if (array_key_exists ('replicas ' , $ currentSettings )) {
71
+ $ this ->algoliaHelper ->setSettings ($ indexName , ['replicas ' => []]);
72
+ $ setReplicasTaskId = $ this ->algoliaHelper ->getLastTaskId ();
73
+ $ this ->algoliaHelper ->waitLastTask ($ indexName , $ setReplicasTaskId );
74
+ if (count ($ currentSettings ['replicas ' ]) > 0 ) {
75
+ foreach ($ currentSettings ['replicas ' ] as $ replicaIndex ) {
76
+ $ this ->algoliaHelper ->deleteIndex ($ replicaIndex );
77
+ }
76
78
}
77
79
}
78
80
}
81
+ } catch (\Exception $ e ) {
82
+ if ($ e ->getMessage () !== 'Index does not exist ' ) {
83
+ throw $ e ;
84
+ }
79
85
}
80
86
foreach ($ storeIds as $ storeId ) {
81
87
$ this ->indicesConfigurator ->saveConfigurationToAlgolia ($ storeId );
0 commit comments