Can the discount be restricted to certain products or collections?

Yes, on the settings page, you can select which collections the discount codes should apply to.

Remember to click the "Save" button at the bottom of the settings page.

Please note Shopify does not allow discount codes for orders to be converted to discount codes for products. To recreate these codes, please see this article.