cancel
Showing results for 
Search instead for 
Did you mean: 

how to set auto generate SKU as default while add new product from admin ?

how to set auto generate SKU as default while add new product from admin ?

Magento Version: 2.1.9

 

I want to set auto-generated SKU while adding a new product from the backend not programmatically.

 

so please suggest me how can i do on magento 2 ?

5 REPLIES

Re: how to set auto generate SKU as default while add new product from admin ?

Hi @yagniksphp,

 

You can configure the pattern used (this is an OOTB feature).

When you type the product name the SKU (and the meta fields) are filled too.

You can configure that behavior on Stores -> Configuration -> Catalog:

 

Área de trabajo 1_005.png

 

 

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: how to set auto generate SKU as default while add new product from admin ?

Thanks for reply,

 

And I already know above configuration regarding auto set value into SKU field based on product name on a new product page.

 

But instead of set default SKU value based on the name on the new product page, we need to set auto-generate value, not product name value that writes into the name field.

 

so please suggest me how can I do it on Magento  2 backend product new product page?

Re: how to set auto generate SKU as default while add new product from admin ?

Hi @yagniksphp,

 

And which will be rule that will set the sku when you enter the new  product?

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: how to set auto generate SKU as default while add new product from admin ?

Thanks again,

 

Yes, In add product page, if you enter name than that value also set into sku field but as per my client requirement, i need to set custom autogenerated number into sku field instead of product name.

 

is it possible in Magento 2?

Re: how to set auto generate SKU as default while add new product from admin ?

Hi @yagniksphp,

 

You can't do that with Magento OOTB but I can imagine 2 possible approaches:

 

  1. Extended the JS that syncs currently the name with the SKU and add your own rule.
  2. Use an observer to process the product before save and set the new SKU to your product with your own rules and validations.

 

I guess I will follow the number 2 if I have to do that customization.

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"