Best Approach for Generating Export File

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

Hi Andrew

Generaly these kinds of situations are handled by having two identificators, first (ID for example) is identical for both, the Product and all of its ProductVariations, the second one (SKU for example) is unique for each ProductVariant. This way you can easily keep track of the SKUs via joiners.

I understand this is quite a high-level view and you might need more details to be able to implement it. So if you need more assistance, please send me a sample of your input files.

Best regards