0

I'd like to filter products by their properties using facets, or in other words, to select multiple values across multiple properties at once.

I've decided to build the query manually, however the following SQL produces less results than I would expect. How do I change it to include all the products?

SELECT COUNT(DISTINCT "spree_products"."id") FROM "spree_products" 
  LEFT OUTER JOIN "spree_product_properties" ON "spree_product_properties"."product_id" = "spree_products"."id" 
  WHERE 
    ("spree_product_properties"."value" in ('lacoste', 'fred perry') AND "spree_product_properties"."property_id" = 161337574) 
    AND 
    ("spree_product_properties"."value" in ('socks', 'shirts') AND "spree_product_properties"."property_id" = 905834903)
2
  • 1
    You want to query products against more than one property and you have also given the SQL query to achieve that? What is the question here? And you need to explain your last sentence a bit further.
    – e-mre
    Dec 29, 2012 at 8:39
  • Sorry for the mess in last sentence, I decided to delete it. In fact, this SQL query is written by me, and it does not produce the result which I want. Jan 11, 2013 at 19:15

1 Answer 1

1

When working with the spree framework for analytics projects, I use existing LookML template in Looker. This way I don't write manual queries and Looker knows the schema against which it generates queries.

My template for spree covers the basic spree installation.

If you plan on integrating Spree with other 3rd party tools, then you will just need to extend the model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.