Repository: saleor/saleor

Issue:
Heroku Deploy Button
Hi!
I was testing out the Heroku deploy button on Readme page of Saleor.

Everything was going fine until it produced this error in fourth step "Run scripts & scale dynos".
`CommandError: Unknown command: 'search_index'`

I believe that it's caused by updated dependencies, any ideas?

populatedb
I'm in trouble, and I do not know what's happening, whenever I give the command

python manage.py populatedb --createsuperuser

I have the following error at the end

Order: #57
Order: #58
Order: #59
Order: #60
Featured products created
Group: Products Manager
Superuser already exists - admin@example.com
CommandError: Unknown command: 'search_index'


Discussion:

Hi @andreyglauzer!
It's definitely a bug, we've recently created new ES back-end in #1193, looks like the search command file was not added to the PR. 
Hello, thank you very much for the feedback.

Is there any way for me to fix it, or should I wait for bug fix?

Resolving patch:
diff --git a/saleor/core/context_processors.py b/saleor/core/context_processors.py
--- a/saleor/core/context_processors.py
+++ b/saleor/core/context_processors.py
@@ -31,7 +31,7 @@ def categories(request):
 
 
 def search_enabled(request):
-    return {'SEARCH_IS_ENABLED': bool(settings.ENABLE_SEARCH)}
+    return {'SEARCH_IS_ENABLED': settings.ENABLE_SEARCH}
 
 
 def webpage_schema(request):
@@ -43,7 +43,7 @@ def webpage_schema(request):
         'url': url,
         'name': site.name,
         'description': site.settings.description}
-    if bool(settings.ENABLE_SEARCH):
+    if settings.ENABLE_SEARCH:
         data['potentialAction'] = {
             '@type': 'SearchAction',
             'target': '%s%s?q={search_term}' % (url, reverse('search:search')),
diff --git a/saleor/core/management/commands/populatedb.py b/saleor/core/management/commands/populatedb.py
--- a/saleor/core/management/commands/populatedb.py
+++ b/saleor/core/management/commands/populatedb.py
@@ -2,6 +2,7 @@
 
 from django.core.management import call_command
 from django.core.management.base import BaseCommand
+from django.conf import settings
 from django.db import connection
 
 from ...utils.random_data import (
@@ -47,7 +48,8 @@ def make_database_faster(self):
             cursor.execute('PRAGMA synchronous = OFF;')
 
     def populate_search_index(self):
-        call_command('search_index', '--rebuild', force=True)
+        if settings.ENABLE_SEARCH:
+            call_command('search_index', '--rebuild', force=True)
 
     def handle(self, *args, **options):
         self.make_database_faster()
diff --git a/saleor/settings.py b/saleor/settings.py
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -357,14 +357,20 @@ def get_host():
 
 LOGOUT_ON_PASSWORD_CHANGE = False
 
-ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL', None)
-ENABLE_SEARCH = bool(ELASTICSEARCH_URL)
 
-if ELASTICSEARCH_URL:
+ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL')
+SEARCHBOX_URL = os.environ.get('SEARCHBOX_URL')
+BONSAI_URL = os.environ.get('BONSAI_URL')
+# We'll support couple of elasticsearch add-ons, but finally we'll use single
+# variable
+ES_URL = ELASTICSEARCH_URL or SEARCHBOX_URL or BONSAI_URL
+ENABLE_SEARCH = bool(ES_URL)
+
+if ENABLE_SEARCH:
     INSTALLED_APPS.append('django_elasticsearch_dsl')
     ELASTICSEARCH_DSL = {
         'default': {
-            'hosts': ELASTICSEARCH_URL
+            'hosts': ES_URL
         },
     }
 


Test patch: