Modifying search facets

93 views
Skip to first unread message

Agnes Gru

unread,
Dec 21, 2014, 11:57:07 PM12/21/14
to django...@googlegroups.com
In the documentation it says that the defult facets are:
OSCAR_SEARCH_FACETS = {
    'fields': {
        # The key for these dicts will be used when passing facet data
        # to the template. Same for the 'queries' dict below.
        'category': {
            'name': _('Category'),
            'field': 'category'
        }
    },
    'queries': {
        'price_range': {
            'name': _('Price range'),
            'field': 'price',
            'queries': [
                # This is a list of (name, query) tuples where the name will
                # be displayed on the front-end.
                (_('0 to 40'), '[0 TO 20]'),
                (_('20 to 40'), '[20 TO 40]'),
                (_('40 to 60'), '[40 TO 60]'),
                (_('60+'), '[60 TO *]'),
            ]
        }
    }
}
But in the search results it also shows 'Type' of product along with 'category' and 'price range'. I want to only modify the price range but, when I put the modified setting in the settings, the 'Type' goes missing. I changed it to below:

OSCAR_SEARCH_FACETS = {
    'fields': {
        # The key for these dicts will be used when passing facet data
        # to the template. Same for the 'queries' dict below.
        'category': {
            'name': _('Category'),
            'field': 'category'
        }
    },
    'queries': {
        'price_range': {
            'name': _('Price range'),
            'field': 'price',
            'queries': [
                # This is a list of (name, query) tuples where the name will
                # be displayed on the front-end.
                (_('0 to 400'), '[0 TO 400]'),
                (_('400 to 600'), '[400 TO 600]'),
                (_('600 to 800'), '[600 TO 800]'),
                (_('800+'), '[800 TO *]'),
            ]
        }
    }'fields': {
        # The key for these dicts will be used when passing facet data
        # to the template. Same for the 'queries' dict below.
        'type': {
            'name': _('Type'),
            'field': 'type'
        }
    },
}
But this gives Internal Server error. Please help.

Alexey Kutalo

unread,
Nov 30, 2015, 4:54:34 AM11/30/15
to django-oscar
Hi, you have to add 
from django.utils.translation import ugettext_lazy as _



Reply all
Reply to author
Forward
0 new messages