I’m trying to wrap my ahead around this issue and need direction. I have two related tables (Product and ProductVariants) that I need to combine and export to CSV, with some caveats. The tables have a one-to-many relationship and I need to export each Product record with all of it’s Product Variants records and include a field in the Product record that is basically a list of all the Product Variants ID’s. This field is used to show all the ProductVariant records that are associated with a Product record. So from a high level, I need to read in both tables, iterate over all the ProductVariant records and keep track of their ID’s, then update the associated Product with associated ProductVariant ID’s, and then export them all to CSV. My problem is I don’t know where to start, particulary keeping track of the ID’s and generating a list to be inserted with the appropriate Product records. Hope this makes sense. So the output would something like this…
SKU | Name | Color | Associated SKU’s
123 | Widget X | Red | NULL
456 | Widget X | Blue | NULL
NULL | Widget X | NULL | 123;456
Thanks!
Andrew