Hi all,

Just wrote this to display the category where the user clicked on the
product in the breadcrumbs when a product is in multiple categories.
Thought I share it someone may find it useful.

def product_cat_url(context):
    request = context['request']
    product = context['product']
    reflist = request.META['HTTP_REFERER'].split('/')
    catname = product.category.filter(slug=reflist[-2])
    if catname:
        return '<a href="%s">%s</a>' % (catname[0].get_absolute_url(),
catname[0].translated_name())
    else:
        return '<a href="%s">%s</a>' % (product.category.all()
[0].get_absolute_url(), product.category.all()[0].translated_name())
register.simple_tag(product_cat_url, takes_context=True)

Use it in place of the default for loop: <li>{% product_cat_url %}</
li>
Note, I don't have subcategories so I did not tested it with one.

lzantal

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to