To fetch product information, use SKProductsRequest if you are using StoreKit 1 APIs and use Product.products(for:) if you are using StoreKit 2 APIs. See Fetching Product Information from the App Store for details.
StoreKit in Testing only uses products that you have defined in your StoreKit configuration file. It doesn't access the sandbox environment.
From Setting up StoreKit testing in Xcode:
There are two types of StoreKit configuration files: local and, in Xcode 14 and later, synced.
Set up a local configuration file if you haven’t set up your app in App Store Connect yet, or you want to try out new types of in-app purchases or subscriptions before you set them up in App Store Connect. The local data is convenient to edit in Xcode, and stands in for the data that otherwise comes from App Store Connect.
Set up a synced configuration file if you have in-app purchases or subscriptions already set up in App Store Connect that you want to test in Xcode.