I am willing to get product SKU value to auto-increment in Magento 2. For example the last product created sku was 100001 then the next product would be 100002 and so on.
Till now Magento does not have such functionality. Though Magento provides the feature to set the mask for autogenerating SKU field.
To do so, go to
Stores > Configuration > Catalog > Product Fields Auto-Generation
and set value of Mask for SKU field.
If you still want to auto-generate SKU field like 100001, 100002 etc., then you need to create a custom module which will observe the event of product edit form load. On this event, check whether it is an old product being edited or a new product is being created.
If a new product is being created, then you would need to get last SKU from the table and fill the value of SKU with (last SKU + 1) value.
Note: Before doing above exercise, you would need to make two changes for SKU attribute:
- Change SKU data type to integer
- Make the SKU field read-only, so that admin cannot change the generated value
Please check and let me know if you have any question.
I've found this module on github which seems to be exactly what you're looking for
From the Link: magento2 auto generate sku for new product based on custom confgiuration. Auto SKU Generator Addon provides the functionality of generating the SKU automatically
Examples 1 : Prefix -> D, Start From -> 1, SKU Length -> 5 D00001, D0002, D0003 ,........
3 : Prefix -> SKU, Start From -> 1, SKU Length -> 7 SKU0001, SKU0002, SKU0003, SKU0004 ,....................