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

Random Image or Random Products - Category Specific

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #21  
Old 02-08-2006, 04:44 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

Anyone got a hack to this that will display a totally random product, no matter what page the user is on? Currently I've got this set up in a spot that shows on every page, and when it goes to non-product/category pages it shows up blank....
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #22  
Old 02-09-2006, 08:08 PM
  moneysaver67's Avatar 
moneysaver67 moneysaver67 is offline
 

Advanced Member
  
Join Date: Nov 2005
Posts: 74
 

Default

Isn't it just a matter of placing this on one of your category pages?

Code:
# # Get products data for current category and store it in an array # $cat = intval($cat); if ($cat) { $category_data = func_query_first("SELECT categoryid_path FROM $sql_tbl[categories] USE INDEX (PRIMARY) WHERE categoryid='$cat'"); $result = func_query("SELECT categoryid FROM $sql_tbl[categories] USE INDEX (pam) WHERE categoryid_path LIKE '$category_data[categoryid_path]/%' AND avail='Y'"); ...


Simply modify the SQL to query the table, but not limiting to $cat ....

then, ORDER BY RAND() and LIMIT 1 ...you should be set. LIMIT 3 if you use the random_products.tpl
__________________
X-Cart 4.0.16-.19 Gold [unix] / DSEFU
Reply With Quote
  #23  
Old 02-19-2006, 11:48 AM
 
tomcoleman tomcoleman is offline
 

Advanced Member
  
Join Date: Feb 2006
Posts: 77
 

Default

I see that thi smod display RANDOM IMG's and Products

I just want mine to display Random Featured Products

Do i need to do all of this mod or is there a shorter way of doing it??
Reply With Quote
  #24  
Old 07-23-2006, 11:59 PM
 
TheWrongGrape TheWrongGrape is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: Los Angeles, CA
Posts: 68
 

Default How to show products from only one category?

I've been able to get this to work great (thanks!) but was wondering if there was something I could modify so that it is:

1. Independent of the category page it is currently being displayed on and instead

2. Shows only random products from a category I specify, for example, I just want it to show products in "Category D" which has a categoryid of 8, no matter what page it's on.

I assume I need to edit random.php and the SQL query, but I don't know how. Any help would be appreciated.

Thank you
Reply With Quote
  #25  
Old 07-24-2006, 12:05 AM
 
TheWrongGrape TheWrongGrape is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: Los Angeles, CA
Posts: 68
 

Default I figured it out!

Sorry, after a few more trials and errors, I figured it out!

In random.php, I simply changed

Code:
# Get products data for current category and store it in an array # $cat = intval($cat);

to

Code:
# Get products data for current category and store it in an array # $cat = 8;

Where the number 8 above is the categoryid for the category who's products I want to display. Hope this helps someone!
Reply With Quote
  #26  
Old 12-19-2006, 06:23 AM
 
robin robin is offline
 

Member
  
Join Date: Aug 2005
Location: Wilmington, NC
Posts: 13
 

Default Re: Random Image or Random Products - Category Specific

This mod is working great I was just wondering if someone could add some functionality I cannot figure out? I would like to have on the home page 4 different specified categorys with 3 random featured products a piece. I would like these to be displayed in a row instead of a column. Is any of this possible?
__________________
X-cart Version: 4.1.3
PHP Version: 5.1.6
MySQL: 3.23.58
OS: Linux
Reply With Quote
  #27  
Old 01-18-2007, 02:16 AM
 
ian@rs.nl ian@rs.nl is offline
 

Newbie
  
Join Date: Jun 2006
Location: Netherlands
Posts: 8
 

Default Re: Random Image or Random Products - Category Specific

Great mod - nearly works

I'm now getting an SQL error when I click on my categories..

"INVALID SQL: 1176 : Key 'pam' doesn't exist in table 'xcart_categories'
SQL QUERY FAILURE:SELECT categoryid FROM xcart_categories USE INDEX (pam) WHERE categoryid_path LIKE '12/%' AND avail='Y'"

Apart from this - the mod is fantastic.

Thanks,
Ian
__________________
xcart v4.1.3 [unix]
Reply With Quote
  #28  
Old 01-18-2007, 03:38 AM
 
ian@rs.nl ian@rs.nl is offline
 

Newbie
  
Join Date: Jun 2006
Location: Netherlands
Posts: 8
 

Default Re: Random Image or Random Products - Category Specific

---don't panic - i've fixed it by switching the INDEX from (pam) to (pa)


Great mod
__________________
xcart v4.1.3 [unix]
Reply With Quote
  #29  
Old 03-21-2007, 06:38 AM
 
ian@rs.nl ian@rs.nl is offline
 

Newbie
  
Join Date: Jun 2006
Location: Netherlands
Posts: 8
 

Default Re: Random Image or Random Products - Category Specific

If anyone's still keeping an eye on this thread was there ever a solution for displaying the product price? Product name was solved but..
__________________
xcart v4.1.3 [unix]
Reply With Quote
  #30  
Old 06-22-2007, 02:59 PM
 
dub713 dub713 is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 56
 

Default Re: Random Image or Random Products - Category Specific

well the mod sounds great but i'll pose one question before i run off and start implementing something that may not work as needed.

i'd ideally like to be able to display 3-4 random products in a row, with images, with links to the product page obviously, but i only want to do this on certain pages where the layout allows for this. mainly the main page, and some other page that don't contain much information other some text.

i know you can call this from where ever you want, but i know there was mention of one random image, and that is was specific to certain categories. the pages i'd want this on have no category, or membership affliation.

is this doable?

thanks,
__________________
X-Cart version 4.1.7 - PHP 5.2. - MySQL server 5.0.41-community-nt - MySQL client 5.0.22 - Web server Apache/2.2.4 (Win32) - PHP/5.2.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 05:01 PM.

   

 
X-Cart forums © 2001-2020