What happened to commerce_discounts->saveDiscounts or How to relate vouchers to product types in Commerce 2?
You now need to set the groups, product types, and purchasables on the discount model directly, then just pass the discount model to the saveDiscount method:

Plugin::getInstance()-&gt;getDiscounts()-&gt;saveDiscount($discount)

An example of setting these things on the discount before saving can be found in the discount controller:

https://github.com/craftcms/commerce/blob/develop/src/controllers/DiscountsController.php#L128-L166