Answers.Body: <p>It's a little awkward, but the documentation has a note about this: <a href="https://craftcommerce.com/docs/product-types#automatic-sku-format" rel="nofollow noreferrer">https://craftcommerce.com/docs/product-types#automatic-sku-format</a></p>
  
  <p>If a product does <em>not</em> have a variant, then you'd just use <code>{slug}</code>.  If it <em>does</em> have a variant, then you'd use <code>{product.slug}</code>.  This should be less awkward in the upcoming Commerce 2 as well.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-27T14:15:46.293Z
Answers.Text: Brad, would there be a way to include an asset field to help in the auto-generation of SKUs? I'd like to have a product image filename be the SKU number. I've tried {productImage.filename} and {product.productImage.filename} and came up empty.
Answers.UserDisplayName: John Johnson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-27T18:29:11.747Z
Answers.Text: Assets are always in array format.  So if you wanted the first Asset, you'd use `{productImage[0].filename}` or `{product.productImage[0].filename}` depending on the variant situation.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-27T20:27:31.937Z
Answers.Text: Worked wonderfully! Except I didn't realize the file extension was included in filename. Any way to avoid the file extension in the SKU?
Answers.UserDisplayName: John Johnson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-02T13:55:21.787Z
Answers.Text: I can't get this to work for variants... I have the variant SKU set to `{product.slug}` and the automatic SKU format for the product type set to the same... but it isn't being translated into anything on the front end.
Answers.UserDisplayName: James Greig
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-07T08:59:24.363Z
Answers.Text: Yes just to add that @BradBell's method does not work for variant products. By setting the value to `{product.title}` the SKU field does not show for any variants, and saving failed because you cant enter a unique SKU. This unfortunately makes commerce near unusable for products with large numbers of variants - you cant expect clients to sit manually entering hundreds of SKU codes that could just auto increment.
Answers.UserDisplayName: Sk446
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-19T18:58:33.677Z
Answers.LastActivityDate: 2017-10-19T18:58:33.677Z
Answers.UserDisplayName: Brad Bell
Body: <p>When I activate Auto Generated SKU's in Craft Commerce, I get the "SKU's cannot be left blank" error when I submit a new product. Isn't it the point to leave them blank so they'll auto generate based on other fields?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-18T22:10:44.060Z
Comments.Text: What is your `Automatic SKU Format` setting set to?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-19T16:02:43.833Z
Comments.Text: I just kept it simple to see how it worked. {product.slug}
Comments.UserDisplayName: John Johnson
Tags: <plugin-craftcommerce>
Title: Auto Generated SKU
ThreadText: # Auto Generated SKU
  
  (Asked by: username_0 on 2017-10-18)
  
  When I activate Auto Generated SKU's in Craft Commerce, I get the "SKU's cannot be left blank" error when I submit a new product. Isn't it the point to leave them blank so they'll auto generate based on other fields?
  
  **Tags:** plugin-craftcommerce
  
  > **Comments:**
  > **username_1**: What is your `Automatic SKU Format` setting set to?  
  > **username_0**: I just kept it simple to see how it worked. {product.slug}  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-10-19. Score: 1 | Accepted answer
  
  It's a little awkward, but the documentation has a note about this: <https://craftcommerce.com/docs/product-types#automatic-sku-format>
  
  If a product does *not* have a variant, then you'd just use `{slug}`. If it *does* have a variant, then you'd use `{product.slug}`. This should be less awkward in the upcoming Commerce 2 as well.
  
  > **Comments:**
  > **username_0**: username_1, would there be a way to include an asset field to help in the auto-generation of SKUs? I'd like to have a product image filename be the SKU number. I've tried {productImage.filename} and {product.productImage.filename} and came up empty.  
  > **username_1**: Assets are always in array format.  So if you wanted the first Asset, you'd use `{productImage[0].filename}` or `{product.productImage[0].filename}` depending on the variant situation.  
  > **username_0**: Worked wonderfully! Except I didn't realize the file extension was included in filename. Any way to avoid the file extension in the SKU?  
  > **username_2**: I can't get this to work for variants... I have the variant SKU set to `{product.slug}` and the automatic SKU format for the product type set to the same... but it isn't being translated into anything on the front end.  
  > **username_3**: Yes just to add that @username_1's method does not work for variant products. By setting the value to `{product.title}` the SKU field does not show for any variants, and saving failed because you cant enter a unique SKU. This unfortunately makes commerce near unusable for products with large numbers of variants - you cant expect clients to sit manually entering hundreds of SKU codes that could just auto increment.  
  
  ---
  
  