The standard wp_unique_post_slug() function will run one query per name collision, leading to a large number of queries being made when a product template is duplicated repeatedly. We can avoid this by doing the unique generation ourselves.