nothing.to.see Posted April 28, 2016 Share Posted April 28, 2016 Hi, Is there any way to generate product reference code automatically on adding product page? I need to create reference code with prefix and it should be auto-incremented. example: Shoes: SHO-0001, SHO-0002 Gloves: GLO-0001. GLO-0002 Or something like that. We can do that manually but it is not healthy way. I think there should be another "better" solution. Any idea would be helpful. Thanks in advance. Link to comment Share on other sites More sharing options...
tuk66 Posted April 28, 2016 Share Posted April 28, 2016 I can imagine to create a very simple module which listens to the actionProductAdd hook and fills non-empty reference. Link to comment Share on other sites More sharing options...
nothing.to.see Posted April 28, 2016 Author Share Posted April 28, 2016 Thank you tuk66, I found a little script like that: <script> function gerar(){ if(document.getElementById('reference').value == '') { hoje = new Date() dia = hoje.getDate() mes = hoje.getMonth() ano = hoje.getFullYear() hora = hoje.getHours(); minutos = hoje.getMinutes(); segundos = hoje.getSeconds(); if (dia < 10) dia = "0" + dia; mes++; if (hora < 10) hora = "0" + hora; if (minutos < 10) minutos = "0" + minutos; if (segundos < 10) segundos = "0" + segundos; document.getElementById('reference').value = ano+''+dia+''+mes+''+segundos+''+hora+''+minutos; } } window.onload = gerar(); </script> But i don't know how to create new module and how to integrate :/ Link to comment Share on other sites More sharing options...
tuk66 Posted April 28, 2016 Share Posted April 28, 2016 There are many free modules, even built-in ones. It is not so tough to adapt a module. http://doc.prestashop.com/display/PS16/Creating+a+first+module 1 Link to comment Share on other sites More sharing options...
nothing.to.see Posted April 28, 2016 Author Share Posted April 28, 2016 (edited) Thank you tuk66. i'm gonna try to create module. I'll let you know the process Edited April 28, 2016 by burak.demiroz (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 14, 2016 Share Posted May 14, 2016 in fact its a .js script only so you dont have to use module you can use it in some .js script that is loaded on product edit page :-) Link to comment Share on other sites More sharing options...
nothing.to.see Posted May 14, 2016 Author Share Posted May 14, 2016 Thanks for tip @vekia ! Link to comment Share on other sites More sharing options...
WEMS Posted July 11, 2016 Share Posted July 11, 2016 We need also that Prestashop are able to auto generate a reference number when you create a new product. Of course the system should not create any duplicate. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now