I'd go for another solution/approach, as detailed below ...
Commerce Bulk Product Creation
You may want to use the Commerce Bulk Product Creation module. Excerpt from its project page:
... facilitates the creation of groups of related products in bulk. Product administrators can select a number of options for various fields, and a product will be created for all possible combinations of these values. Out of the box, only list fields are supported for this, but an API exists to enable other types of fields for 'combination creation'.
Attention: this module doesn't have an official release yet (only an RC6), though with over 1.200 reported installs, it seems it is pretty stable / trustworthy.
Another option is to use the Commerce Backoffice module, e.g. because of the auto creation of product display nodes. It provides the backoffice functionality present in Commerce Kickstart (V2), and contains these sub-modules:
- Commerce Backoffice Product (commerce_backoffice_product).
- Commerce Backoffice Order (commerce_backoffice_order).
- Commerce Backoffice Content (commerce_backoffice_content).
This module (and a few dependencies) provides the rich store owner experience that has made Commerce Kickstart 2 so popular (and prevents that you have to install the entire Commerce Kickstart distribution). And there is a great video introduction about it also.
Note: if you use Commerce Backoffice, you most probably also want to use the Shiny administration theme, also used in Commerce Kickstart (V2).