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

Limiting the number of featured products displayed and randomising

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 06-29-2008, 10:56 PM
 
EN4U EN4U is offline
 

eXpert
  
Join Date: Feb 2008
Location: AZ
Posts: 379
 

Default Re: Limiting the number of featured products displayed and randomising

Quote:
Originally Posted by yamiya
if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); }

#
# Select from featured products table
#

$user_account['membershipid'] = !empty($user_account['membershipid'])?$user_account['membershipid']:0;

$old_search_data = $search_data["products"];
$old_mode = $mode;
$old_page = $page;

$search_data["products"] = array();
$search_data["products"]["forsale"] = "Y";
$search_data["products"]["sort_condition"] = "$sql_tbl[featured_products].product_order";
$search_data["products"]['_']['inner_joins']['featured_products'] = array(
"on" => "$sql_tbl[products].productid=$sql_tbl[featured_products].productid AND $sql_tbl[featured_products].avail='Y' AND $sql_tbl[featured_products].categoryid='".intval($cat)."'"
);

$REQUEST_METHOD = "GET";
$mode = "search";
include $xcart_dir."/include/search.php";

$search_data["products"] = $old_search_data;
x_session_save("search_data");
$mode = $old_mode;
$page = $old_page;
unset($old_search_data, $old_mode, $old_page);

if (!empty($active_modules["Subscriptions"])) {
include_once $xcart_dir."/modules/Subscriptions/subscription.php";
}
$smarty->clear_assign("products");

$smarty->assign("navigation_script","home.php?cat=$cat&sor t=$sort&sort_direction=$sort_direction");

#Randomize featured products
shuffle($products);
array_splice($products,$config["Appearance"]["products_per_page"]);

$smarty->assign("f_products",$products);
$search_data = '';
$products = array();
unset($search_data, $products);
?>

This works, but just shuffles what i have chosen. What id like to happen is the system just randomizes products from within my store that are active.

is this possible??
__________________
Regards, Dan
X-Cart Gold Version 4.1.10

1 - One page checkout
2 - Image Generator
3 - CSDEO Pro
4 - Shop By Price
5 - Next - Previous
6 - On Sale
7 - Shop By Price

8 - Froogle & Google Base Feed
9 - Buy Together
10 - Customer Loyalty Points
11 - Customer Reward Points
Customer Reward Points Referral Add-on
12 - Product Reviews
13 - Other Custom Modifications
----------------------
http://www.townsqjewelry.com/
http://www.eroticnights4u.com/ <---- Adult Oriented - Toys
Reply With Quote
  #12  
Old 12-02-2009, 12:08 AM
 
dmic dmic is offline
 

Advanced Member
  
Join Date: Nov 2005
Posts: 63
 

Default Re: Limiting the number of featured products displayed and randomising

thanks for this code - works well on my site

Dave
Reply With Quote
  #13  
Old 12-29-2009, 12:36 PM
 
sparker2 sparker2 is offline
 

eXpert
  
Join Date: Feb 2007
Posts: 290
 

Default Re: Limiting the number of featured products displayed and randomising

Hi Guys, I am using the code also on my site but cannot get rid of the subsequent page links. Please Help!

I am trying to get rid of

Result pages: 1 2 3 >

in Featured Products only. Thanks in advance.
__________________
Shareen
sparker2@cox.net
http://www.stitches4u.com
X-Cart Version 4.5.0 with Smart Template vs 4.4.x
Reply With Quote
  #14  
Old 02-06-2010, 11:20 AM
 
craven craven is offline
 

Advanced Member
  
Join Date: Dec 2004
Posts: 50
 

Default Re: Limiting the number of featured products displayed and randomising

Has anyone got this to work on 4.3.0 yet? Just like to Limit the Featured Products on Homepage and Categories to 6 and have them display random featured products. Is this easy on 4.3.0? Thanks in advance
__________________
Version 4.3.2
Reply With Quote
  #15  
Old 05-12-2010, 07:14 PM
 
sales@weddingaccents.com sales@weddingaccents.com is offline
 

Member
  
Join Date: Aug 2005
Location: San Jose
Posts: 15
 

Smile Re: Limiting the number of featured products displayed and randomising

Hello,

Great Tip... Thanks, I just tried it and it works great. Biggest thing was that I wanted to show more then 2 or 4 to one page and then a link to another page. I'm not sure I really need the randomizer but that's cool.

Thanks Again
Best Regards
John Crow


Quote:
Originally Posted by SpinyMan
Hi,

open "featured_products.php" and add 2 lines of code

before a line


it will show 6 random products with the pages to other featured products (if more exists).
If this variant doesn't meen your wish try this one:

put this code

before this line:
__________________
http://www.weddingaccents.com/home.php/Version%204.0.14
Dell 3.9 gighz/1Gig Ram/Winows XP Pro service pack 2
Microsoft Internet Exploder V6.0.2
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 01:17 PM.

   

 
X-Cart forums © 2001-2020