Post by johnjj » Thu Jan 28, 2010 4:34 am

Hello.

Instead of the product name in the Admin panel, in trying to add a auto generating ID. Can please some one help me.

Thanks :)

Newbie

Posts

Joined
Thu Jan 28, 2010 4:31 am

Post by i2Paq » Thu Jan 28, 2010 4:39 am

What have you come up with so far?

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by johnjj » Thu Jan 28, 2010 9:14 am

hi

Nothing, but if you can tell me what to do I can manage to do sumthing.

Thanks.

Newbie

Posts

Joined
Thu Jan 28, 2010 4:31 am

Post by Qphoria » Thu Jan 28, 2010 10:53 pm

you need to give a lot more info. what starts the id? 00001? 000A? AAAA? 1234?
How will it work? you just want the name field to auto-populate with the next available number?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by johnjj » Wed Feb 03, 2010 11:33 am

Hello

Thank for you r support, this is what i wanted n came up with in the file product_form.tpl


<?PHP
$random_id_length =6;
$rnd_id = crypt(uniqid(rand(),001));
$rnd_id = strip_tags(stripslashes($rnd_id));
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));
$rnd_id = substr($rnd_id,0,$random_id_length);

# DB settings
$mysql_server = 'localhost';
$mysql_user = '######';
$mysql_passwd = '#####';
$mysql_db = #######';


# Connect to database
$conn = mysql_connect($mysql_server, $mysql_user, $mysql_passwd);

if (!$conn)
die("Unable to connect to db server!");

# Select the db
mysql_select_db ($mysql_db, $conn) || die("Unable to select db $mysql_db");

$sL = "select count(*) from product";

$result = mysql_query($sL);
$details = mysql_fetch_array($result);
$new_cnt = $details[0] + 1;
$cnt_id = 'AA0000'.$new_cnt;

echo "<input type='text' name='model' readonly='readonly' value='$cnt_id'>";
?>

Newbie

Posts

Joined
Thu Jan 28, 2010 4:31 am
Who is online

Users browsing this forum: No registered users and 3 guests