Hi!

I am working on a template tag showing the inventory status for a product with 
two option groups (e.g. color and size) in a two-dimensional array like this:

     | Small | Medium | Large
------+-------+--------+-------
red   |     2 |      2 |    10
blue  |     0 |      5 |     0
green |    12 |     10 |     3

My plan is to query for the relevant option groups, i.e. 
product.configurableproduct.option_group.select_related().all(). Then I would 
loop over them, basically like this:

inventory = []
for color in [c for c in colors.option_set.all()
            if c in product.configurableproduct.get_valid_options()]:
   sublist = []
   for size in [s for s in colors.option_set.all()
                if s in product.configurableproduct.get_valid_options()]:
        sublist.append(product.objects.filter(SOME CRITERIA)[0].items_in_stock)
   inventory.append(sublist)

That piece of code has several problems: 
product.configurableproduct.get_valid_options() returns option combinations and 
not valid options from one option group only. And then there are the criteria 
needed in product.objects.filter() to query a specific product variation. Do I 
need to make the relevant slugs and query for those, or is there a possibility 
to query for the "parent" product instead?

I'm stuck and would be glad about any hints!

Thanks!

Ben

-- 
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