TL;DR Dont do from AEM.
You are trying to generate sitemap for pages generated by non-aem application. Its easier to split into content-sitemap.xml (generated by AEM) and products-sitemap.xml generated by your BE application and merge using sitemap-index.xml. Normal practice for huge websites running pages with diverse applications. Its cleaner to maintain multiple sitemaps.
If you still compulsory need AEM only to generate sitemap, you have to hit API to pull URLs from BE and generate. Not advisable.