I'm making a test class that creates 5 orders and upon insert, I get the error that you need to add products to orders.
List<Product2> clothProds = [SELECT Id FROM Product2 WHERE Name='Clothing Voucher']; List<Product2> foodProd = [SELECT Id FROM Product2 WHERE Name='Food Pantry'];
to obtain the products I want for each order. Some will be food, others clothing.
I see an object "Order Product" in the org that isn't a Custom object, and has lookup fields for Order and for Product2, so I'm guessing this is what I need to make the association of Orders and their Products, but I can't for the life of me find the API Name or any info on how to make this in Apex.
All I'm really trying to do is insert Orders, and I have a way of getting the Products I need, and bridging these two things to insert them is where I'm having trouble. There are some triggers on Order insert, but they don't change the status or anything. Maybe there are complications there, but I don't think they're affecting this, so I'm hoping it's something standard that I'm just missing that somebody here can help me identify.