Search code examples
pythondjangodjango-oscar

Filtering and Sorting Products in Django Oscar ? In-built feature or have to custom build?


Not a programming question per se, more of a feature question. I was trying Django-Oscar and find it great. Is there in-built way to filter the products by categories?

And also is there in-built way to sort products by prices? I can build it myself, was just asking in-case already some feature is available. I tried reading its docs : http://django-oscar.readthedocs.org/. Nothing much I found.


Solution

  • First install Solr 4. eg on OSX you could:

    $ brew tap homebrew/versions
    $ brew install solr4
    

    (has to be Solr 4 in order to use the ready-made conf from Oscar)

    Then get a copy of the Oscar source code:

    $ git clone https://github.com/django-oscar/django-oscar.git
    

    Then replace the conf in the Solr example site (what the Solr server serves by default) with a symlink to the Solr conf included with the Oscar demo site, roughly as per the Oscar docs here

    First find your Solr install:

    $ brew info solr4
    homebrew/versions/solr4: stable 4.10.4
    Enterprise search platform from Apache Lucene project
    https://lucene.apache.org/solr/
    Conflicts with: solr
    /usr/local/Cellar/solr4/4.10.4 (4658 files, 248M) *
      Built from source
    

    Then have a look, here is where I've symlinked the conf:

    $ ls -l /usr/local/Cellar/solr4/4.10.4/example/solr/collection1/
    total 24
    -rw-r--r--   1 me  wheel  2146  8 Sep  2014 README.txt
    lrwxr-xr-x   1 me  wheel    44  7 Jun 13:37 conf -> <path to oscar repo>/sites/demo/deploy/solr
    drwxr-xr-x  24 me  wheel   816 27 Feb  2015 conf.original
    -rw-r--r--   1 me  wheel    16  8 Sep  2014 core.properties
    drwxr-xr-x   4 me  wheel   136  6 Jun 17:03 data