Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Adding/Modifying Fields in the Main Product Table

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-23-2006, 07:34 AM
 
Stikx Stikx is offline
 

Member
  
Join Date: Nov 2006
Location: UK
Posts: 23
 

Smile 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.
__________________
X-cart 4.1.3 pro Linux 2.6.17
Music Website Selling Digital Downloads
Reply With Quote
  #2  
Old 11-23-2006, 12:01 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default 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
__________________
xcartmods.co.uk
Reply With Quote
  #3  
Old 11-24-2006, 04:39 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default 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}
__________________
xcartmods.co.uk
Reply With Quote

The following 2 users thank PhilJ for this useful post:
2inchesofwater (07-22-2009), am2003 (09-21-2010)
  #4  
Old 11-24-2006, 06:11 AM
 
Stikx Stikx is offline
 

Member
  
Join Date: Nov 2006
Location: UK
Posts: 23
 

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

Excellent, that looks straightforward - appreciate your help.
__________________
X-cart 4.1.3 pro Linux 2.6.17
Music Website Selling Digital Downloads
Reply With Quote
  #5  
Old 12-01-2006, 06:07 AM
 
Stikx Stikx is offline
 

Member
  
Join Date: Nov 2006
Location: UK
Posts: 23
 

Default 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
__________________
X-cart 4.1.3 pro Linux 2.6.17
Music Website Selling Digital Downloads
Reply With Quote
  #6  
Old 01-20-2007, 09:20 AM
 
zachvenice zachvenice is offline
 

Member
  
Join Date: Jan 2007
Posts: 23
 

Default 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?
__________________
zachvenice
xcart v4.0.19
hosted at Lunarpages
Reply With Quote
  #7  
Old 02-12-2007, 11:13 AM
 
JP908 JP908 is offline
 

Member
  
Join Date: Jun 2005
Location: USA
Posts: 21
 

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

Is it possible to use this new fiels in the Product Varients table?
Thanks.
__________________
JP
UNIX
v4.1.11
v4.2
v4.3
v4.4
Reply With Quote
  #8  
Old 04-26-2007, 01:40 PM
 
bugdoubt bugdoubt is offline
 

Member
  
Join Date: Aug 2005
Posts: 25
 

Default 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
__________________
Version 4.0.14
Reply With Quote
  #9  
Old 04-26-2007, 02:10 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

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

It's meant for v4.1.x stores, not v4.0.x
__________________
xcartmods.co.uk
Reply With Quote
  #10  
Old 07-07-2008, 07:00 AM
 
dgreen dgreen is offline
 

Advanced Member
  
Join Date: May 2005
Posts: 85
 

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

how can I use it in the simple search?

Thank you
Gitty
__________________
X-Cart version 4.1.10
upgraded from 4.0.13 myself slowly and with help from xcart forums. Thanks all!

http://www.discountseforim.com
Hebrew Seforim and Jewish Books
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:03 PM.

   

 
X-Cart forums © 2001-2020