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

Recommended products.

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-26-2003, 02:29 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default Recommended products.

Anyone know how to make the recommended products list in alphabetical order rather than buy products number using the code below?

<?
/************************************************** ***************************\
+-----------------------------------------------------------------------------+
| X-Cart |
| Copyright (c) 2001-2003 Ruslan R. Fazliev <rrf@rrf.ru> |
| All rights reserved. |
+-----------------------------------------------------------------------------+
| PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" |
| FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE |
| AT THE FOLLOWING URL: http://www.x-cart.com/license.php |
| |
| THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE |
| THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. |
| FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING |
| AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). |
| PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT |
| CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, |
| COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY |
| (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS |
| LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS |
| AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND |
| OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS |
| AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE |
| THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.|
| THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. |
| |
| The Initial Developer of the Original Code is Ruslan R. Fazliev |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2003 |
| Ruslan R. Fazliev. All Rights Reserved. |
+-----------------------------------------------------------------------------+
\************************************************* ****************************/

#
# $Id: recommends.php,v 1.7.2.1 2003/06/02 11:57:43 svowl Exp $
#
# Recommends list
#


#
# Get products data for current category and store it into $products array
#

$products_id = func_query("SELECT productid, categoryid FROM $sql_tbl[products] WHERE forsale='Y' AND categoryid =" . $cat . " and avail>0");

if ($config["Modules"]["select_recommends_list_randomly"] == "Y") {
$str = "";
$query_condition = " AND (";
srand((double)microtime()*1000000);
$rnd = rand(0, count($products_id)-1);
$query_condition .= "productid='".$products_id[$rnd][productid]."'";
for($i = 5; $i < $config["Modules"]["number_of_recommends"] - 1; $i++) {
$rnd = rand(5, count($products_id)-1);
if (!ereg("'".$products_id[$rnd][productid]."'", $query_condition)) {
$query_condition .= " OR productid='".$products_id[$rnd][productid]."'";
}
}
$query_condition .= ")";
$query = "SELECT * FROM $sql_tbl[products] WHERE forsale='Y' AND categoryid =" . $cat . " and avail>0".$query_condition;
}
else
$query = "select distinct sp2.productid, p.* from $sql_tbl[stats_customers_products] as sp1, $sql_tbl[stats_customers_products] as sp2, $sql_tbl[products] as p where sp1.productid='$productid' and sp1.login=sp2.login and sp2.productid!='$productid' and p.productid=sp2.productid and p.forsale='Y' and p.avail>0 ORDER BY p.product LIMIT ".$config["Modules"]["number_of_recommends"];

$recommends = func_query($query);
$smarty->assign("recommends",$recommends);
?>

Also can it be set so that there is always x number of products displayed and not jump around e.g. one time there will be 5 products displayed the next time 4 etc. I always want it a constant number.

Thanks in advance

Dan Winchester
Reply With Quote
  #2  
Old 09-26-2003, 04:31 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

try:

Code:
<? /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2003 Ruslan R. Fazliev <rrf@rrf.ru> | | All rights reserved. | +-----------------------------------------------------------------------------+ | PLEASE READ THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" | | FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE | | AT THE FOLLOWING URL: http://www.x-cart.com/license.php | | | | THIS AGREEMENT EXPRESSES THE TERMS AND CONDITIONS ON WHICH YOU MAY USE | | THIS SOFTWARE PROGRAM AND ASSOCIATED DOCUMENTATION THAT RUSLAN R. | | FAZLIEV (hereinafter referred to as "THE AUTHOR") IS FURNISHING OR MAKING | | AVAILABLE TO YOU WITH THIS AGREEMENT (COLLECTIVELY, THE "SOFTWARE"). | | PLEASE REVIEW THE TERMS AND CONDITIONS OF THIS LICENSE AGREEMENT | | CAREFULLY BEFORE INSTALLING OR USING THE SOFTWARE. BY INSTALLING, | | COPYING OR OTHERWISE USING THE SOFTWARE, YOU AND YOUR COMPANY | | (COLLECTIVELY, "YOU") ARE ACCEPTING AND AGREEING TO THE TERMS OF THIS | | LICENSE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY THIS | | AGREEMENT, DO NOT INSTALL OR USE THE SOFTWARE. VARIOUS COPYRIGHTS AND | | OTHER INTELLECTUAL PROPERTY RIGHTS PROTECT THE SOFTWARE. THIS | | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES YOU LIMITED RIGHTS TO USE | | THE SOFTWARE AND NOT AN AGREEMENT FOR SALE OR FOR TRANSFER OF TITLE.| | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2003 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: recommends.php,v 1.7.2.1 2003/06/02 11:57:43 svowl Exp $ # # Recommends list # # # Get products data for current category and store it into $products array # $products_id = func_query("SELECT productid, categoryid FROM $sql_tbl[products] WHERE forsale='Y' AND categoryid =" . $cat . " and avail>0"); if ($config["Modules"]["select_recommends_list_randomly"] == "Y") { $query = "SELECT * FROM $sql_tbl[products] WHERE forsale='Y' AND categoryid =$cat and avail>0 order by RAND(), product limit ".$config["Modules"]["number_of_recommends"]; } else $query = "select distinct sp2.productid, p.* from $sql_tbl[stats_customers_products] as sp1, $sql_tbl[stats_customers_products] as sp2, $sql_tbl[products] as p where sp1.productid='$productid' and sp1.login=sp2.login and sp2.productid!='$productid' and p.productid=sp2.productid and p.forsale='Y' and p.avail>0 ORDER BY p.product LIMIT ".$config["Modules"]["number_of_recommends"]; $recommends = func_query($query); $smarty->assign("recommends",$recommends); ?>

haven't tested it, but it will be close
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 09-26-2003, 04:40 AM
 
info@sjidesign.com info@sjidesign.com is offline
 

Advanced Member
  
Join Date: Aug 2003
Posts: 46
 

Default

Hi Duncan,

Doesn't seem to put them into alphabetical order, just random product numbers by the look of it.

Looks as though it's made the number of products always 10 though, can this be set to the number of products in each category e.g. for wooden toys 21 products, games 10 etc?
Reply With Quote
  #4  
Old 09-29-2003, 09:30 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

The number of products is a global setting.

I can make the mod for you to get this working is you want to email me for a quote.

Cheers
__________________
ex x-cart guru
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 02:44 AM.

   

 
X-Cart forums © 2001-2020