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)
-   -   Limiting the number of featured products displayed and randomising (https://forum.x-cart.com/showthread.php?t=35813)

EN4U 06-29-2008 10:56 PM

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??

dmic 12-02-2009 12:08 AM

Re: Limiting the number of featured products displayed and randomising
 
thanks for this code - works well on my site

Dave

sparker2 12-29-2009 12:36 PM

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.

craven 02-06-2010 11:20 AM

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

sales@weddingaccents.com 05-12-2010 07:14 PM

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:



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

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