Product Options
Posted: Fri Nov 19, 2010 2:59 pm
Since there is somewhat of a debate about how product options should and could be handled in 1.5 and beyond, I would like to offer my suggestions. The goal is to create a schema that:

You would query for a product's options using something like:
Which would return:
Thoughts?
- Can have an unlimited number of options for the product.
- Can keep track of the stock, image, price and cost of each unique combination of options for the product.
- Has global options rather than ones tied exclusively to the product.

You would query for a product's options using something like:
Code: Select all
SELECT DISTINCT
o.option_id,
o.name as `option`,
ov.option_value_id,
ov.name as `option_value`
FROM `option` o
LEFT JOIN `option_value` ov ON (o.option_id = ov.option_id)
LEFT JOIN `sku_to_option_value` s2ov ON (ov.option_value_id = s2ov.option_value_id)
LEFT JOIN `sku` s ON (s2ov.sku_id = s.sku_id)
WHERE s.product_id = '1'
ORDER BY o.option_id, ov.option_value_id;
Code: Select all
option_id option_name option_value_id option_name
--------- ----------- --------------- -----------
1 Size 1 Large
1 Size 2 X-Large
1 Size 3 XX-Large
2 Color 4 White
2 Color 5 Blue