301 redirect / SEO approach

Hi,

I am doing Migration from SW5 to SW6 and I need to set up redirect 301.

In Shopware 5, the number in the URL represents the product ID in the database.

In Shopware 6, the database structure is different and there are no product IDs in the URLs.

We are looking for a proper SEO approach to generate 301 redirects. We could generate the redirects based on the SW5 and SW6 databases using code, but this would require manual effort.

Has anyone developed a sensible method or automatic solution for this?

The problem is that after migrating to SW6, it is difficult to generate redirects to the old URLs and we are losing SEO rankings.