Are you talking about specifically hard coding the product names? What is your naming convention for the product names and the layout names. Is it specifically 'Product 1" to Layout "P1" (which would be easier).
Please give some concrete examples
If you add a text field to your product table, you can put the layout name in that field to assign a specific layout to that product. You'd then use the "layout name by calculation" option and refer to this field to control what layout is pulled up.
If you added a number field to your product table, you can put the layout number in that field in order to assign a specific layout. You'd then use the "layout number by calculation" option.
Using a field like this allows you to dynamically assign different products to layouts best formatted for that product via data entry rather than having to update your script as you might with other methods. But be careful of design changes that modify the name of a layout (first method) or the layout's order (second method) as they will "break" this approach until you make corresponding updates to the data in this field in your products table.