It seems a simple feature to me, but I can't find a way to do the trick.

I've uploaded the products of my Drupal Commerce store with a CSV table that contains in SKU column a sequential set of integers starting on 1 until, say, 8000. I would like to register a new product that automatically generates the SKU field with 8001, the next product with 8002, and so on. I already have the AutoSKU module installed with a Commerce Kickstart 2 profile installed. But I can't see a way to generates the SKU value like I said.

Is there a simple way/module that facilitates this?


I tried with Serial Field module. I created a field of type "serial". It's hidden.

Then I put in AutoSKU Parameters, SKU Pattern the token [commerce-product:field_book_code]. Now the SKU is automatically generated, but it starts with a number greater than the total of products that store has, and when I add a product, the SKU is incremented by 10.

Anyone could help me?

2 Answers 2


I had this issue and certain modules wouldn't work for me really bc the client wanted to start at a certain number, rather than at 0.

I ended up pre-filling the SKU field (because it's required and has to be filled out to save) and on entity_create per variation, I would do an entity query, find the product with the highest SKU, add one and set the SKU to be that number.

This works with variations because each one is its' own entity and runs the code to search for highest the SKU each time.

  • Uh, would you mind to share the snippet you ended up with to find the highest SKU?
    – leymannx
    Dec 23, 2018 at 9:03

I'm not sure if it works but using AutoSKU and Serial Field Module you probably can make it.

  • Thanks for the quick reply. I'm now trying to use Serial Field to do solve this. In discussion drupal.org/node/702408, @iantresman say that "I would guess this could be done in conjunction with the CCK Serial Field module which "provides an auto-increment (serial) field", which in turn can be used as a CCK file tokens in the Pattern for the SKU.". I'm looking for the way to do that. Searching a pattern in AutoSKU parameters, Sku Pattern (admin/commerce/config/product-variation-types/my_product_type) I can't find any serial pattern. Do you know how to do?
    – Caco
    Oct 15, 2014 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.