Update collection from a array

Hi, I’m building an small ERP, so I have orders with inside an array with all the product

I want when I’m creating it, to update the stock for the product collection.

so I think I need to create a loop, but how can I find the ID from the array to compare with the product Id of the product collection ?