3
3
namespace Algolia \AlgoliaSearch \Console \Command ;
4
4
5
5
use Algolia \AlgoliaSearch \Api \Product \ReplicaManagerInterface ;
6
+ use Algolia \AlgoliaSearch \Exceptions \AlgoliaException ;
6
7
use Algolia \AlgoliaSearch \Exceptions \BadRequestException ;
7
8
use Algolia \AlgoliaSearch \Service \StoreNameFetcher ;
8
9
use Magento \Framework \Console \Cli ;
10
+ use Magento \Framework \Exception \LocalizedException ;
11
+ use Magento \Framework \Exception \NoSuchEntityException ;
9
12
use Magento \Store \Model \StoreManagerInterface ;
10
13
use Symfony \Component \Console \Command \Command ;
11
14
use Symfony \Component \Console \Input \InputArgument ;
@@ -62,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
62
65
{
63
66
$ this ->output = $ output ;
64
67
$ this ->input = $ input ;
65
-
68
+
66
69
$ storeIds = (array ) $ input ->getArgument (self ::STORE_ARGUMENT );
67
70
$ unused = $ input ->getOption (self ::UNUSED_OPTION );
68
71
@@ -136,6 +139,11 @@ protected function confirmDeleteUnused(array $unusedReplicas): bool
136
139
return true ;
137
140
}
138
141
142
+ /**
143
+ * @throws NoSuchEntityException
144
+ * @throws AlgoliaException
145
+ * @throws LocalizedException
146
+ */
139
147
protected function deleteReplicas (array $ storeIds = [], bool $ unused = false ): void
140
148
{
141
149
if (count ($ storeIds )) {
@@ -147,12 +155,22 @@ protected function deleteReplicas(array $storeIds = [], bool $unused = false): v
147
155
}
148
156
}
149
157
158
+ /**
159
+ * @throws NoSuchEntityException
160
+ * @throws LocalizedException
161
+ * @throws AlgoliaException
162
+ */
150
163
protected function deleteReplicasForStore (int $ storeId , bool $ unused = false ): void
151
164
{
152
165
$ this ->output ->writeln ('<info>Deleting ' . ($ unused ? ' unused ' : ' ' ) . 'replicas for ' . $ this ->storeNameFetcher ->getStoreName ($ storeId ) . '...</info> ' );
153
166
$ this ->replicaManager ->deleteReplicasFromAlgolia ($ storeId , $ unused );
154
167
}
155
168
169
+ /**
170
+ * @throws NoSuchEntityException
171
+ * @throws LocalizedException
172
+ * @throws AlgoliaException
173
+ */
156
174
protected function deleteReplicasForAllStores (bool $ unused = false ): void
157
175
{
158
176
$ storeIds = array_keys ($ this ->storeManager ->getStores ());
0 commit comments