0

I've been stuck on this for quite some time using C#. We have a large table with varying product attributes (color, size, texture) and their associated values (red, green, blue, etc). There are any number of attributes/values in the system and these change for each product. An example for some random product would be:

ID 1 - Colour - Red
ID 2 - Colour - Green
ID 3 - Colour - Blue
ID 4 - Size - Small
ID 5 - Size - Medium
ID 6 - Size - Large
ID 7 - Texture - Glossy
ID 8 - Texture - Matte

I need to click a button and generate all product variations, so something like this:

Variation 1 - Red (1), Small (4), Glossy (7)
Variation 2 - Red (1), Small (4), Matte (8)
Variation 3 - Red (1), Medium (5), Glossy (7)
...
Variation 18 - Blue (3), Large (6), Matte (8)

I've been trying to use a tree data structure to add attributes to each level, then each path would represent exactly what I need. But I haven't been able to get this to work and I may be overthinking this. All I really need is 18 lists of 3 integers that represent the ID's of the various variations:

1, 4, 7
1, 4, 8
1, 5, 7
...

Perhaps I should be looking at recursion instead but I couldn't come up with a proper algorithm for that either. Any help would be appreciated.

Tree diagram

chris358
  • 139
  • 5

0 Answers0