How does Magento 2 sku generated automatically?
-
07-03-2021 - |
Question
I want to know how does Magento 2 sku generated automaticlly.
I wonder when I type product name while creating new product in admin then its sku is automatically typed in sku field.
I researched much and found that there is a functionality called "Modifier" in Magento 2 in which product edit section can be added/edited with some extra features.
Also found that there are two methods in modifier class, "modifyMeta" & "modifyData" that can be used to add/edit product edit fields.
But I am totally dumb that how sku is generated automatically and which file I will have to override to make sku in our own way.
Right now sku is generated based on product name but I want to make it something like somedigits+autogenerated_sku eg: 00000testsku.
Is there anyone who can hints at it and give some light on it?
Solution
For sku generation has settings: Stores -> Configuration -> Catalog
Change Mask for SKU to somedigits_{{name}}
[Update]
SKU js component: Magento_Catalog/js/components/import-handler
Location: vendor/magento/module-catalog/view/adminhtml/web/js/components/import-handler.js
Overwrite this component what you want here.