How to get the last product id that exists in DataBase on page /Admin/Product/Create?

1 month ago
3.90

I want to add +1 to the last product id that exists in my database and then insert it to SKU field before I create product manually in admin.

How can I do it in this file?
Administration\Views\Product\_CreateOrUpdate.Info.cshtml

Thanks.
1 month ago
RE: " last product id that exists in my database "
If you're using SQL Server, that may not be reliable because Id is an IDENTITY type column.  SQL Server will cache a bunch of Ids for performance reasons.  An identity can jump / skip values; usually, it occurs when the SQL Server instance is being forced to restart.

If you really need it, there is a way to Disable the IDENTITY CACHE option at the database level.
1 month ago
You can not do that by updating the Administration\Views\Product\_CreateOrUpdate.Info.cshtml view because Id is IDENTITY type column and it will automatically assign the value to the ID.

You can do it by updating it in the database as suggested by @NewYork.

Best regards,
Faiz