View Single Post
  #5  
Old 10-17-2008, 06:14 AM
 
Jerrad Jerrad is offline
 

X-Adept
  
Join Date: Nov 2004
Location: The Netherlands
Posts: 484
 

Default Re: Exclude categories from recommends...

I've added the code (red text in the bold line) to my recommends.php and it seems to work.
Unfortunately it 'only' excludes the category that is added and not the subcategories from that certain category.

Could it do any harm adding all the categories (25+) separately to the recommends and/or slow down the storefront, where the recommends are displayed?

All suggestions are very welcomed!
Thanks!


Code:
<?php /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2005 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-2005 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: recommends.php,v 1.1.2.4 2005/01/12 07:41:43 svowl Exp $ # # Recommends list # if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); } # # Get products data for current category and store it into $products array # $avail_condition = ""; if ($config["General"]["unlimited_products"] == "N" && $config["General"]["disable_outofstock_products"] == "Y") { $avail_condition = " AND $sql_tbl[products].avail>0 "; } $lng_condition = " AND $sql_tbl[products_lng].code='$store_language'"; $lng_fields = "IF ($sql_tbl[products_lng].product IS NOT NULL,$sql_tbl[products_lng].product, $sql_tbl[products].product) AS product, IF ($sql_tbl[products_lng].descr IS NOT NULL,$sql_tbl[products_lng].descr, $sql_tbl[products].descr) AS descr, IF ($sql_tbl[products_lng].full_descr IS NOT NULL,$sql_tbl[products_lng].full_descr, $sql_tbl[products].fulldescr) AS fulldescr"; if ($config["Modules"]["select_recommends_list_randomly"] == "Y") { $query_ids = array(); $rnd = rand(); $products_id = func_query("SELECT $sql_tbl[products].productid FROM $sql_tbl[products] USE INDEX (fi,fia), $sql_tbl[products_categories] USE INDEX (cpm), $sql_tbl[categories] USE INDEX (iam) WHERE $sql_tbl[products].forsale='Y' AND $sql_tbl[products].productid = $sql_tbl[products_categories].productid AND $sql_tbl[products_categories].main = 'Y' AND $sql_tbl[categories].categoryid = $sql_tbl[products_categories].categoryid AND $sql_tbl[categories].categoryid != 548 AND $sql_tbl[categories].membership IN ('".@$user_account['membership']."','') ".$avail_condition." ORDER BY RAND(NOW()+$rnd) LIMIT ".$config["Modules"]["number_of_recommends"]); if(!empty($products_id)) { foreach($products_id as $p) { $query_ids[] = $p['productid']; } } unset($products_id); } if ($config["Modules"]["select_recommends_list_randomly"] == "Y" && count($query_ids)>0) { $query = "SELECT $sql_tbl[products].*, $lng_fields FROM $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE $sql_tbl[products].productid IN ('".join("','",$query_ids)."')"; # Add extra code for Prices to Show $recommends_prices = func_query("select * from $sql_tbl[pricing] where quantity='1' and productid in (".join(",",$query_ids).")"); $smarty->assign("recommends_prices",$recommends_prices); $query = "SELECT $sql_tbl[products].*, $lng_fields FROM $sql_tbl[products] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE $sql_tbl[products].forsale='Y' ".$avail_condition." AND $sql_tbl[products].productid IN (".join(",",$query_ids).")"; #End Add extra code for Prices to Show } else $query = "SELECT DISTINCT sp2.productid, $sql_tbl[products].*, $lng_fields FROM $sql_tbl[stats_customers_products] as sp1, $sql_tbl[stats_customers_products] AS sp2, $sql_tbl[products], $sql_tbl[products_categories], $sql_tbl[categories] LEFT JOIN $sql_tbl[products_lng] ON $sql_tbl[products].productid=$sql_tbl[products_lng].productid $lng_condition WHERE sp1.productid='$productid' AND sp1.login=sp2.login AND sp2.productid!='$productid' AND $sql_tbl[products].productid=sp2.productid AND $sql_tbl[products].forsale='Y' AND $sql_tbl[products].productid = $sql_tbl[products_categories].productid AND $sql_tbl[products_categories].main = 'Y' AND $sql_tbl[categories].categoryid = $sql_tbl[products_categories].categoryid AND $sql_tbl[categories].membership IN ('".@$user_account['membership']."','') ".$avail_condition." ORDER BY $sql_tbl[products].product LIMIT ".$config["Modules"]["number_of_recommends"]; $recommends = func_query($query); $smarty->assign("recommends",$recommends); ?>
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote