File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ echo ' Saving APPID...'
4
+ php bin/magento config:set algoliasearch_credentials/credentials/application_id " ${ALGOLIA_APPLICATION_ID} "
5
+ echo ' Saving Search Key...'
6
+ php bin/magento config:set algoliasearch_credentials/credentials/search_only_api_key " ${ALGOLIA_SEARCH_API_KEY} "
7
+ echo ' Saving API key...'
8
+ php bin/magento config:set algoliasearch_credentials/credentials/api_key " ${ALGOLIA_API_KEY} "
9
+ echo ' Saving prefix...'
10
+ php bin/magento config:set algoliasearch_credentials/credentials/index_prefix " ${MAGENTO_CLOUD_ENVIRONMENT} _"
11
+ echo ' Saving enable instant...'
12
+ php bin/magento config:set algoliasearch_instant/instant/is_instant_enabled " 1"
13
+
14
+ php bin/magento indexer:reindex algolia_products
15
+ php bin/magento indexer:reindex algolia_categories
16
+ php bin/magento indexer:reindex algolia_pages
17
+ php bin/magento indexer:reindex algolia_suggestions
18
+ php bin/magento indexer:reindex algolia_additional_sections
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Magento \Framework \App \Bootstrap ;
4
+ require '/app/app/bootstrap.php ' ;
5
+
6
+ $ bootstrap = Bootstrap::create (BP , $ _SERVER );
7
+ $ objectManager = $ bootstrap ->getObjectManager ();
8
+
9
+ $ algoliaHelper = $ objectManager ->get ('\Algolia\AlgoliaSearch\Helper\AlgoliaHelper ' );
10
+ $ indexNamePrefix = getenv ('MAGENTO_CLOUD_ENVIRONMENT ' );
11
+
12
+ /**
13
+ * @param $algoliaHelper Algolia\AlgoliaSearch\Helper\AlgoliaHelper
14
+ * @param array $indices
15
+ */
16
+ function deleteIndexes ($ algoliaHelper , array $ indices , $ indexNamePrefix )
17
+ {
18
+ foreach ($ indices ['items ' ] as $ index ) {
19
+ $ name = $ index ['name ' ];
20
+
21
+ if (mb_strpos ($ name , $ indexNamePrefix ) === 0 ) {
22
+ try {
23
+ $ algoliaHelper ->deleteIndex ($ name );
24
+ echo 'Index " ' . $ name . '" has been deleted. ' ;
25
+ echo "\n" ;
26
+ } catch (Exception $ e ) {
27
+ // Might be a replica
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ if ($ algoliaHelper ) {
34
+ $ indices = $ algoliaHelper ->listIndexes ();
35
+ if (count ($ indices ) > 0 ) {
36
+ deleteIndexes ($ algoliaHelper , $ indices , $ indexNamePrefix );
37
+ }
38
+
39
+ $ replicas = $ algoliaHelper ->listIndexes ();
40
+ if (count ($ replicas ) > 0 ) {
41
+ deleteIndexes ($ algoliaHelper , $ replicas , $ indexNamePrefix );
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments