X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Adding/Modifying Fields in the Main Product Table (https://forum.x-cart.com/showthread.php?t=26844)

Stikx 11-23-2006 07:34 AM

Adding/Modifying Fields in the Main Product Table
 
Does anybody know where to find info about modifying or adding fields in the main products table (as opposed to adding an extra field)?
How complicated is this?
Which files (sql/php/tpl ??) are associated this type of mod?

Example: -
What are the implications of adding a new field "Artist" and displaying it on the main category or products listing page?


Why not use extra fields? - The exported table is seperate to the main products table and makes editing in a spreadsheet cumbersome.

As I am a newcomer forgive me if I have misunderstood anything basic and I look forward to your replies.

PhilJ 11-23-2006 12:01 PM

Re: Adding/Modifying Fields in the Main Product Table
 
If you take a look at some of my freebie mods, you'll pick up a few tips on how to add custom fields to the products table and manage them in admin. It's not too hard, failing that I'll post a quick tutorial.
Cheers,
Phil

PhilJ 11-24-2006 04:39 AM

Re: Adding/Modifying Fields in the Main Product Table
 
OK, here's how it's done in v4.1.x ...
1) Add a new product text field called 'artist'...
Patch the database...
Code:

ALTER TABLE `xcart_products` ADD `artist` TEXT NOT NULL ;
2) include/product_modify.php
Look for...
Code:

# Update product data
Within...
Code:

$query_data = array( ... );
Along similar lines add...
Code:

"artist" => $artist,
3) skin1/main/product_details.tpl
Add this code in a suitable place...
Code:

<tr>
 {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if}
 <td class="FormButton" nowrap="nowrap">Artist</td>
 <td class="ProductDetails"><input type="text" name="artist" size="18" value="{if $product.productid eq ""}{else}{$product.artist}{/if}" /></td>
</tr>

Or for predefined options...
Code:

<tr>
 {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if}
 <td class="FormButton" nowrap="nowrap">Artist</td>
 <td class="ProductDetails">
 <select name="artist">
 <option value=""{if $product.artist eq ""} selected{/if}>None</option>
 <option value="Van Gogh"{if $product.artist eq "Van Gogh"} selected{/if}>Van Gogh</option>
 <option value="Picasso"{if $product.artist eq "Picasso"} selected{/if}>Picasso</option>
 </select>
</td>
</tr>

That's it!
To use the field on your product page, (skin1/customer/main/product.tpl), use this code...
Code:

{$product.artist}
To use the field on your products page, (skin1/customer/main/products.tpl or products_t.tpl), use this code...
Code:

{$products[product].artist}
v4.4.x use this code
Code:

{$product.artist}

Stikx 11-24-2006 06:11 AM

Re: Adding/Modifying Fields in the Main Product Table
 
Excellent, that looks straightforward - appreciate your help.

Stikx 12-01-2006 06:07 AM

Re: Adding/Modifying Fields in the Main Product Table
 
Just tried the above code - worked first time, suddenly everything seems so much easier - cheers Phil

zachvenice 01-20-2007 09:20 AM

Re: Adding/Modifying Fields in the Main Product Table
 
What I don't understand is why I would have to add the extra field to the database even AFTER I've added it to the product through the Admin area. Where is this data stored in the first place? I have v4.0.19, will this still work?

JP908 02-12-2007 11:13 AM

Re: Adding/Modifying Fields in the Main Product Table
 
Is it possible to use this new fiels in the Product Varients table?
Thanks.

bugdoubt 04-26-2007 01:40 PM

Re: Adding/Modifying Fields in the Main Product Table
 
Be warned while this works trying to "modify products" after this is frustrating becasue there are some steps missing you will get sql errors

PhilJ 04-26-2007 02:10 PM

Re: Adding/Modifying Fields in the Main Product Table
 
It's meant for v4.1.x stores, not v4.0.x

dgreen 07-07-2008 07:00 AM

Re: Adding/Modifying Fields in the Main Product Table
 
how can I use it in the simple search?

Thank you
Gitty

dgreen 07-29-2008 05:37 AM

Re: Adding/Modifying Fields in the Main Product Table
 
how can I add my new field to the simple and advanced searches?

does anyone have any ideas?

carpart4u 10-01-2008 09:21 AM

Re: Adding/Modifying Fields in the Main Product Table
 
Quote:

Originally Posted by PhilJ
OK, here's how it's done in v4.1.x ...
1) Add a new product text field called 'artist'...
Patch the database...
Code:

ALTER TABLE `xcart_products` ADD `artist` TEXT NOT NULL ;
2) include/product_modify.php
Look for...
Code:

# Update product data
Within...
Code:

$query_data = array( ... );
Along similar lines add...
Code:

"artist" => $artist,
3) skin1/main/product_details.tpl
Add this code in a suitable place...
Code:

<tr>
 {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if}
 <td class="FormButton" nowrap="nowrap">Artist</td>
 <td class="ProductDetails"><input type="text" name="artist" size="18" value="{if $product.productid eq ""}{else}{$product.artist}{/if}" /></td>
</tr>

Or for predefined options...
Code:

<tr>
 {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if}
 <td class="FormButton" nowrap="nowrap">Artist</td>
 <td class="ProductDetails">
 <select name="artist">
 <option value=""{if $product.artist eq ""} selected{/if}>None</option>
 <option value="Van Gogh"{if $product.artist eq "Van Gogh"} selected{/if}>Van Gogh</option>
 <option value="Picasso"{if $product.artist eq "Picasso"} selected{/if}>Picasso</option>
 </select>
</td>
</tr>

That's it!
To use the field on your product page, (skin1/customer/main/product.tpl), use this code...
Code:

{$product.artist}
To use the field on your products page, (skin1/customer/main/products.tpl or products_t.tpl), use this code...
Code:

{$products[product].artist}


Hi Phil,

I can add a custom field successfully.
When i try to import cvs database...
I got error messages:
Quote:

An error occurred during the verification of the CSV file. Please check your CSV file and fix the problem, then try again.

Date: 01-Oct-2008 10:19:14
Launched by: master

Error on line 2: Column 'BIN_LOCATION' is not supposed to be in the section 'PRODUCTS' (PRODUCTS):
!PRODUCTID;!PRODUCTCODE;!BIN_LOCATION

if that's not supposed to be in the section 'PRODUCTS', which section should I use? THANKS

Learner 03-28-2009 02:46 AM

Re: Adding/Modifying Fields in the Main Product Table
 
I want to add some more fields like Pack Size & Attribute in a small text field and also the content type=Liquid,Solid etc.... in a select box in the product item card.Also I want to import that field values via 3x-4x import. How can I able to do that?Kindly help me to do this.

Thanks to all again.

Learner 04-07-2009 02:23 AM

Re: Adding/Modifying Fields in the Main Product Table
 
Quote:

Originally Posted by PhilJ
OK, here's how it's done in v4.1.x ...
That's it!
To use the field on your product page, (skin1/customer/main/product.tpl), use this code...
Code:

{$product.artist}
To use the field on your products page, (skin1/customer/main/products.tpl or products_t.tpl), use this code...
Code:

{$products[product].artist}


Thanks PhilJ for such effort.But can you help me where to add {$product.artist} in
(skin1/customer/main/product.tpl) file?

Learner 04-09-2009 04:39 AM

Re: Adding/Modifying Fields in the Main Product Table
 
Quote:

Originally Posted by PhilJ
OK, here's how it's done in v4.1.x ...
1) Add a new product text field called 'artist'...
Patch the database...
Code:

ALTER TABLE `xcart_products` ADD `artist` TEXT NOT NULL ;
2) include/product_modify.php
Look for...
Code:

# Update product data
Within...
Code:

$query_data = array( ... );
Along similar lines add...
Code:

"artist" => $artist,
3) skin1/main/product_details.tpl
Add this code in a suitable place...
Code:

<tr>
 {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if}
 <td class="FormButton" nowrap="nowrap">Artist</td>
 <td class="ProductDetails"><input type="text" name="artist" size="18" value="{if $product.productid eq ""}{else}{$product.artist}{/if}" /></td>
</tr>

Or for predefined options...
Code:

<tr>
 {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if}
 <td class="FormButton" nowrap="nowrap">Artist</td>
 <td class="ProductDetails">
 <select name="artist">
 <option value=""{if $product.artist eq ""} selected{/if}>None</option>
 <option value="Van Gogh"{if $product.artist eq "Van Gogh"} selected{/if}>Van Gogh</option>
 <option value="Picasso"{if $product.artist eq "Picasso"} selected{/if}>Picasso</option>
 </select>
</td>
</tr>

That's it!
To use the field on your product page, (skin1/customer/main/product.tpl), use this code...
Code:

{$product.artist}
To use the field on your products page, (skin1/customer/main/products.tpl or products_t.tpl), use this code...
Code:

{$products[product].artist}


Thanks PhilJ for those fine codes.But I can not know where to add {$products[product].artist} in (skin1/customer/main/product.tpl) file?Can you guide me?

Also is it possible to import from 3x-4x import?

Thanks to all.

Learner 06-18-2009 10:37 PM

Re: Adding/Modifying Fields in the Main Product Table
 
Hi,
May I request some help from the Forum please?

I am here --- > ](*,)

Thanks in advance...

Learner 07-08-2009 10:29 PM

Re: Adding/Modifying Fields in the Main Product Table
 
Any response from forum please!!! I really need some help.

Thanks to all.

ADDISON 07-08-2009 11:12 PM

Re: Adding/Modifying Fields in the Main Product Table
 
Thank you PhilJ. People are affraid X-Cart because there are no information how to change the code. If QT will take in consideration to write a developer manual, it will be much easier for everyone to go on their own.

Learner 07-08-2009 11:44 PM

Re: Adding/Modifying Fields in the Main Product Table
 
Hi am2003,
Can you help me a little bit !!!

Thanks to all.

Mathieu-911 07-16-2009 04:55 AM

Re: Adding/Modifying Fields in the Main Product Table
 
Hello!
I'm new with x-cart.
I have try to add one field fallowing the steps you've writen. The data is displayed well but no modification to the data is reported to DataBase. What's wrong ?

To DataBase:
ALTER TABLE `xcart_products` ADD `descrauteurs` TEXT DEFAULT NULL;

in product_modify.php, i added: "descrauteurs" => $descrauteurs at the wright place
and in product_details.tpl, i added:
<tr>
{if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[descrauteurs]" /></td>{/if}
<td class="FormButton" nowrap="nowrap">{$lng.lbl_descrauteurs}* :</td>
<td class="ProductDetails">
{include file="main/textarea.tpl" name="descrauteurs" cols=45 rows=12 class="InputWidth" data=$product.descrauteurs width="80%" btn_rows=4}
</td>
</tr>

What's the problem ????
Tanks for your help.

sofiane 05-31-2012 01:48 AM

Re: Adding/Modifying Fields in the Main Product Table
 
Bringing this back to life.

Okay so we have the extra field linked to the database and displaying the value for the new column, in this case "artist".

Now, how do we allow our vendors to modify those values? How do we modify those values when adding a new product? When I go inot the admin area and I want to add a new product I can't modify the value for "artist" because its not included in the form. How do we include it?

Thanks.

elmirage001 04-16-2019 02:34 PM

Re: Adding/Modifying Fields in the Main Product Table
 
Quote:

Originally Posted by PhilJ
OK, here's how it's done in v4.1.x ...
1) Add a new product text field called 'artist'...
Patch the database...
Code:

ALTER TABLE `xcart_products` ADD `artist` TEXT NOT NULL ;
2) include/product_modify.php
Look for...
Code:

# Update product data
Within...
Code:

$query_data = array( ... );
Along similar lines add...
Code:

"artist" => $artist,
3) skin1/main/product_details.tpl
Add this code in a suitable place...
Code:

<tr>
 {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if}
 <td class="FormButton" nowrap="nowrap">Artist</td>
 <td class="ProductDetails"><input type="text" name="artist" size="18" value="{if $product.productid eq ""}{else}{$product.artist}{/if}" /></td>
</tr>

Or for predefined options...
Code:

<tr>
 {if $geid ne ''}<td width="15" class="TableSubHead"><input type="checkbox" value="Y" name="fields[artist]" /></td>{/if}
 <td class="FormButton" nowrap="nowrap">Artist</td>
 <td class="ProductDetails">
 <select name="artist">
 <option value=""{if $product.artist eq ""} selected{/if}>None</option>
 <option value="Van Gogh"{if $product.artist eq "Van Gogh"} selected{/if}>Van Gogh</option>
 <option value="Picasso"{if $product.artist eq "Picasso"} selected{/if}>Picasso</option>
 </select>
</td>
</tr>

That's it!
To use the field on your product page, (skin1/customer/main/product.tpl), use this code...
Code:

{$product.artist}
To use the field on your products page, (skin1/customer/main/products.tpl or products_t.tpl), use this code...
Code:

{$products[product].artist}
v4.4.x use this code
Code:

{$product.artist}

I used this to create a custom Image Alt Tag for product images instead of it defaulting to the product name.

Thank you Phil! This may be an old post but it's a GREAT one!!

Paul


All times are GMT -8. The time now is 04:42 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.