File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -735,20 +735,30 @@ public function deleteInactiveProducts($storeId)
735
735
736
736
$ objectIds = array ();
737
737
$ counter = 0 ;
738
- foreach ($ index ->browse ('' , array ('attributesToRetrieve ' => array ('objectID ' ))) as $ hit ) {
739
- $ objectIds [] = $ hit ['objectID ' ];
740
- $ counter ++;
741
738
742
- if ($ counter === 1000 ) {
743
- $ this ->deleteInactiveIds ($ storeId , $ objectIds , $ indexName );
739
+ try {
740
+ foreach ($ index ->browse ('' , array ('attributesToRetrieve ' => array ('objectID ' ))) as $ hit ) {
741
+ $ objectIds [] = $ hit ['objectID ' ];
742
+ $ counter ++;
743
+
744
+ if ($ counter === 1000 ) {
745
+ $ this ->deleteInactiveIds ($ storeId , $ objectIds , $ indexName );
744
746
745
- $ objectIds = array ();
746
- $ counter = 0 ;
747
+ $ objectIds = array ();
748
+ $ counter = 0 ;
749
+ }
747
750
}
748
- }
749
751
750
- if (!empty ($ objectIds )) {
751
- $ this ->deleteInactiveIds ($ storeId , $ objectIds , $ indexName );
752
+ if (!empty ($ objectIds )) {
753
+ $ this ->deleteInactiveIds ($ storeId , $ objectIds , $ indexName );
754
+ }
755
+ } catch (\AlgoliaSearch \AlgoliaException $ e ) {
756
+ $ message = $ e ->getMessage ();
757
+
758
+ // Fail silently if the exception tells that Index does not exist
759
+ if (!preg_match ('/^Index (.*) does not exist$/ ' , $ message )) {
760
+ throw $ e ;
761
+ }
752
762
}
753
763
}
754
764
You can’t perform that action at this time.
0 commit comments