Integrating Haystack with Satchmo

84 views
Skip to first unread message

Swaroop Shankar V

unread,
May 8, 2012, 4:11:30 AM5/8/12
to Satchmo users
Hello All,
I want to implement a search functionality in my project and is seriously thinking about using haystack. I am not sure if it will work well with satchmo or how to integrate haystac with satchmo. Do anyone have experience in integrating the haystack with satchmo? If so could you please provide some details on how to do it.

Thanks and Regards,

Swaroop Shankar V

ma...@cuthemustard.com

unread,
May 8, 2012, 1:50:21 PM5/8/12
to satchm...@googlegroups.com
I think this is a fantastic idea! The satchmo search is not so good and very hard to customise. It is way faster and WAY better just to implement Haystack.

I just did this on my latest project and it works very well. I am using the default haystack views and the Woosh backend, which works fine for smaller sites and is very easy to implement. The only satchmo-related thing you need to do is deactivate its search urls once you have set up haystack the way you want. I had set Haystack up with url(r'^haystack include('haystack.urls')), and then swithed it to url(r'^search/', include('haystack.urls')) when it was ready. To deactivate satchmo_search simply:

from satchmo_utils.urlhelper import delete_named_urlpattern


delete_named_urlpattern(urlpatterns, 'satchmo_search')


... before the haystack search urlpattern.

Swaroop Shankar V

unread,
May 10, 2012, 2:17:05 AM5/10/12
to satchm...@googlegroups.com
Thanks Marco,

I just saw in some posts that haystack wont work well with satchmo. So could you tell me how you created the search index file for the satchmo models?

Thanks and Regards,

Swaroop Shankar V



--
You received this message because you are subscribed to the Google Groups "Satchmo users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/satchmo-users/-/80GgkCw_uccJ.
To post to this group, send email to satchm...@googlegroups.com.
To unsubscribe from this group, send email to satchmo-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en.

ma...@cuthemustard.com

unread,
May 10, 2012, 1:59:18 PM5/10/12
to satchm...@googlegroups.com
So far I haven't noticed any problems, and aside from the initial part of the learning curve, where I had to grasp the basic functioning of Haystack, the implementation was super simple (albeit very basic). I set the search_index in my localsite app, but you can set it in any app. You'll notice that I am not including variations in the search results.

/localsite/search_index.py

from haystack.indexes import *
from haystack import site
from product.models import Product
   
class ProductIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
   
    def index_queryset(self):
        return Product.objects.active(variations=False)

site.register(Product, ProductIndex)

Then you need a template to specify what parts of the Product model to search in. I have satchmo_ext.brand installed, which is the reason why I needed to extend the search capabilities of Satchmo in the first place, so I included it in the text document.

/templates/search/indexes/product/

{% for b in object.brand_set.active %}
    {{ b.translation.name }}
{% endfor %}
{{ object.slug }}
{{ object.translated_name }}
{{ object.translated_short_description }}
{{ object.translated_description }}

{% with options=object.configurableproduct.get_valid_options %}
    {% for opt in options %}
        {{ opt }}
    {% endfor %}
{% endwith %}

One of the reasons that I believe it is a good idea to use Haystack rather than the Satchmo search functions is the ample documentation that is provided for implementing Haystack. My implementation is pretty much as basic as you can get, but you could do so much with it and is scalable.

Swaroop Shankar V



To unsubscribe from this group, send email to satchmo-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages