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

Exclude categories from recommends...

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-16-2008, 04:18 AM
 
Jerrad Jerrad is offline
 

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

Default Exclude categories from recommends...

We're planning to add some categories to our store which contain adult/erotic products. Before these categories can be viewed customers will see a message that these categories contain erotic images and text.

Because of obvious reasons we don't want any of the products of these categories to show up in the recommends, which we use on the storefront of our store.

I've found this (old) post about excluding one category from the recommends:
http://forum.x-cart.com/showthread.php?t=21990&highlight=exclude+category+ recommends

Does anybody know what the code would be for excluding several categories from the recommends?

Any help is very appreciated. Many thanks in advance!

Jerrad
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote
  #2  
Old 10-16-2008, 01:18 PM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default Re: Exclude categories from recommends...

How many categories are you trying to exclude? The reference you gave could possible be modified to include several (up to 3 or 4 maybe) just by adding more "AND"s. Also, the modification excludes main categories and subcategories, so if you had a category named "Adult" you could exclude all of the subcategories of "Adult".
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #3  
Old 10-16-2008, 01:34 PM
 
Jerrad Jerrad is offline
 

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

Default Re: Exclude categories from recommends...

Thanks for your reply, JWait!

There are around 8 main categories, which each will have from 3 up to 10 subcategories.

Do I understand you correctly that excluding a main category like for example "Adult", will also automatically exclude all subcategories of that category?
Or must each subcategory excluded separately?

Thanks again!
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote
  #4  
Old 10-16-2008, 04:36 PM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default Re: Exclude categories from recommends...

I'm just going by the original question in the other thread at http://forum.x-cart.com/showthread.php?t=21990 -
"Anyone know of a way to exclude the products of 1 specified main category (and its subcategories) from ever displaying in randomly generated Recommended Products results?"

I have not tried it, so I don't know if it works, but it does make sense that if a main category is excluded that any subcategories of the main category would be excluded also. Another thing to consider is that the thread was from 2006, and the version listed are 4.0.x branches. There may have been changes since then.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #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
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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:43 AM.

   

 
X-Cart forums © 2001-2020