Add variation to a product thru code
I'm doing a module here where the module read a xml url n turn those url into product array. The product is a book information.
I'm having problem creating a variation of product using code. All the book from that xml should have both Digital and Print edition product.
I managed to make the book into a product, but the next step to create a variation for it did not work. It either overwrite the previous edition and left with the latest or it create 2 separate product.
Is there somewhere here I can refer to?