How can we add product code ?

KiralyVlad

No avatar

2006-11-04 13:10

I want to insert a unique product code (ID) for every product available, how can I do that ?

treewood (OpenSolution)

Avatar: treewood

2006-11-04 13:28

KiralyVlad - search forum about new field in product form

KiralyVlad

No avatar

2006-11-04 15:29

I've searched the forum. I've found nothing to help me in this problem. I am using Quick.Cart v.1.4. Basicly, as you said, I want to add a new field in the product form.

Thank you.

Shadowed

No avatar

2006-11-04 15:41

http://opensolution.org/Quick.Cart/forum/?p=readTopic&nr=1798

Is that it ?

Shadowed

KiralyVlad

No avatar

2006-11-04 16:58

I've tried playing around... but no success so far.... I've edited the template files:
templates/admin/products_list.tpl
templates/admin/products_form.tpl

edited the php scripts
core/products.php
core/products-admin.php
core/products-ff.php

I searched for [sShortDescription] , copied all instances of the code containing that and replaced sShortDescription with sProductCode ....
I managed to make the code save the productcode in the db/products.php file, but I don't know how to get it out from there, into the templates/admin/products-list.tpl and into the edit page that comes up when you edit a product....

I've added
<td>$lang[ProductCode]</td>
right after the ID
and
<td>$aList[sProductCode]</td>
right after the $aList[iProduct]</td>

KiralyVlad

No avatar

2006-11-04 17:06

Also found this code in products-ff.php


$oFF
->setRow( Array( $iProduct$sName$fPrice$sDescriptionShort$iStatus$iPosition ) );
$oFF->setData( Array( 51023) );



and changed it to


$oFF
->setRow( Array( $iProduct, ,$sProductCode$sName$fPrice$sDescriptionShort$iStatus$iPosition ) );
$oFF->setData( Array( 651023) );


But I`m not sure what the second line does, I thought you should check if it's ok.
Thank's

treewood (OpenSolution)

Avatar: treewood

2006-11-04 17:49

KiralyVlad - thank GOD You know PHP. It will be easier to explain.
change to

$oFF->setRow( Array( $iProduct$sName$fPrice$sDescriptionShort$iStatus$iPosition$sProductCode ) );
$oFF->setData( Array( 510234) );


You need to check functions throwProductsData, throwProduct to see results

KiralyVlad

No avatar

2006-11-04 18:05

The truth is I`m not so good at PHP... I`m so stuck now I can`t even see the way out of this....

Treewood, let`s suppose I've got a fresh, untouched script.... What must I modify, and how?
Let's assume I've just entered the html code for the templates, with the variable sProductCode..... Could you please explain from top to bottom what should I modify in the scripting part ? I would greatly appreciate it.

KiralyVlad

No avatar

2006-11-04 19:43

Anyone ?

KiralyVlad

No avatar

2006-11-04 23:55

Let me be more specific... I`ll tell you exactly what I did

In templates/admin/products_form.tpl I've added:

<php> Array(
Array( 'sName' )
,Array( 'aCategories[]' )
,Array( 'fPrice', 'float' )
,Array( 'sDescriptionShort' )
,Array( 'iPosition', 'int', '-99', null, '>=', 'false' )
,Array( 'iPosition', 'int', '999', null, '=<', 'false' )
,Array( 'sProductCode' )
) );"></php>

and

<php><!-- productcode -->
<tr>
<td style='text-align: right; padding: 5px;'>
<strong>$lang[ProductCode]: </strong>
</td>
<td>
<input type="text" name="sProductCode" value="$aData[sProductCode]" size="15" maxlenght="8" class="input" />
</td>
</tr>
<!-- end productcode --></php>

templates/admin/products_list.tpl is currently untouched as I never managed to come to an end

In core/products.php I've added:

<php>
for( $i = 0; $i < $iCount; $i++ ){
list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'], $aList['sProductCode'] ) = $aData[$i];</php>

and

<php> if( empty( $aList['sProductCode'] ) )
$aList['sProductCode'] = '&nbsp;';
else
$aList['sProductCode'] = ereg_replace( '\|n\|', '', $aList['sProductCode'] );</php>

and

<php> $aList['sDescriptionFull'] = $aList[1];
list( $aList['iProduct'], $aList['sName'], $aList['fPrice'], $aList['sDescriptionShort'], $aList['iStatus'], $aList['iPosition'], $aList['sProductCode'] ) = $aData;</php>

In core/products-admin.php I've added:

<php> $aForm['sProductCode'] = changeTxt( $aForm['sProductCode'], 'Nds' );</php>

In core/products-ff.php I've added:

<php>extract( $aForm );
$oFF->setRow( Array( $iProduct, $sName, $fPrice, $sDescriptionShort, $iStatus, $iPosition, $sProductCode ) );
$oFF->setData( Array( 5, 1, 0, 2, 3, 4, 6 ) );</php>

I've tried inserting $aList[sProductCode] in the templates/products_list.tpl and it doesn't print out anything... (also tried to add it to pa.productsInRow.tpl and as well, it prints out nothing)

KiralyVlad

No avatar

2006-11-04 23:56

Sorry about the

 tags..... I was too tired to notice that its p

hp ] not < php >

KiralyVlad

No avatar

2006-11-05 01:44

Ok.... I've found out the problem.... all was right,
When I disabled the Productattributes plugin they showed up..... thanks for your help.

Back to top
about us | contact