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

Extra field value in products list

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-03-2012, 01:55 AM
 
tomsell tomsell is offline
 

Member
  
Join Date: Feb 2009
Posts: 13
 

Default Extra field value in products list

Hi, is there a change to add specific Extra Field value to show in products list? For example under {$product.descr}? Thanks for advance!
__________________
4.1.11
Reply With Quote
  #2  
Old 05-03-2012, 05:54 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Extra field value in products list

First you need to enable the extra field as a product search option in the admin. General Settings > Product Search - set the field as active.

Then you should have the field assigned and you can use:
{$product.extra_fields[0].field_value}

Or better you could loop through the extra fields array with a foreach statement if you have multiple fields.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
Petepots (06-01-2014)
  #3  
Old 05-04-2012, 10:18 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default Re: Extra field value in products list

I was trying to achieve this as well, and was sucessful with the approach of looping through the extra fields array. See the thread http://forum.x-cart.com/showthread.php?t=63314 where I wanted to show extra field data on the invoice (to help us in pulling products to fill the order. The same looping approach worked on the product list pages.

Totaltec...if your suggestion of {$product.extra_fields[0].field_value} works (I assume the [0] is replaced by the index for the extra field value you want to display) then it seems it would be more efficient than looping through ALL the extra fields for each product being displayed while browsing a catagory or when viewing search results. What do you think?
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #4  
Old 05-04-2012, 10:20 AM
 
tartaglia tartaglia is offline
 

X-Adept
  
Join Date: May 2006
Location: Dallas, TX
Posts: 575
 

Default Re: Extra field value in products list

oh yea, please note that I had been sucessful on a develoment instance of 4.4.5.
__________________
David Coggan
Carolyn Nussbaum Music Company
X-Cart v4.5.4 Gold +
LiteCommerce v2.2.41 (previous 6 years)
Reply With Quote
  #5  
Old 05-05-2012, 07:54 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Extra field value in products list

Looping through a list does not take much processor power, so I think that either method is fine if it consistently produces the result that you want.

Referencing the value directly is more efficient, but less flexible. If you use a loop, you can check to make sure you have the right value from the loop before executing your code. Either way is going to be fine.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
tartaglia (05-05-2012)
  #6  
Old 10-24-2012, 11:22 AM
 
hamid hamid is offline
 

Senior Member
  
Join Date: Apr 2004
Posts: 107
 

Default Re: Extra field value in products list

I'm using xcart 4.0.16 - and I also want to display extra fields on the products list page as well but this doesn't seem to work.

On the products list page, debug console lists the $extra_fields array like this:

{$extra_fields}
Array (2)
0 => Array (5)
fieldid => 1
provider => me
field => Bundle001
value => empty
active => Y
1 => Array (5)
fieldid => 2
provider => me
field => Bundle002
value => empty
active => Y


However on the product page debug console lists $extra_fields array like this:

{$extra_fields}
Array (2)

0 => Array (7)
fieldid => 1
provider => me
field => Bundle001
value => empty
active => Y
field_value => 2
is_value => Y
1 => Array (7)
fieldid => 2
provider => me
field => Bundle002
value => empty
active => Y
field_value => 7
is_value => Y


(The extra fields are displayed correctly on the product page, but not on the products list page)

As you can see, the products list page is missing the field_value, and is_value items.

Please can anybody help?
__________________
X-Cart Gold v4.6.5
Reply With Quote
  #7  
Old 10-24-2012, 12:23 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Extra field value in products list

hamid,
The problem is probably larger than this. On the product page the variable $extra_fields can be assumed to be specific to that product. On the list it has many products to loop through. The $extra_fields variable is of no use to you.

You will need to alter the MySQL query for the products list to also include the extra field values for each product. Then when looping through the products you can access the individual values for each product.

Unfortunately I do not have access to such an old version of XC. To get you started, first determine the name of the array that has the products assigned to it. Then search through the files to find where this variable is assigned. Then look at the query that pulls the info from the database. Add your changes for including the extra field values in the array.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #8  
Old 10-24-2012, 01:49 PM
 
hamid hamid is offline
 

Senior Member
  
Join Date: Apr 2004
Posts: 107
 

Default Re: Extra field value in products list

Thanks for your reply Totaltec.

Yes, I assumed it was something more complicated.

I thought it might be the extra_fields.php file itself that is the issue, but it's probably not.

When I'm on the products list page, I can see from the debug console an array called $products, which contains all the product information, but not the extra fields.

Is there any way to put the extra fields into $products?
__________________
X-Cart Gold v4.6.5
Reply With Quote
  #9  
Old 10-24-2012, 02:30 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Extra field value in products list

Quote:
Originally Posted by hamid
Is there any way to put the extra fields into $products?
That is basically what I was describing, and is the correct course of action. To accomplish this you will need to examine how the $extra_fields array is generated, and incorporate that into $products. Not an easy task unless you are skilled in PHP/MySQL. But the examples are all there, you just need to look at the code.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #10  
Old 10-25-2012, 02:27 AM
 
hamid hamid is offline
 

Senior Member
  
Join Date: Apr 2004
Posts: 107
 

Default Re: Extra field value in products list

Thanks again for your reply Totaltec.

Ah yes, php/mysql - unfortunately I'm not so skilled with this, and I don't really have enough time to delve into it - so I doubt I'll be able to make this happen
__________________
X-Cart Gold v4.6.5
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 12:17 AM.

   

 
X-Cart forums © 2001-2020