View Single Post
  #3  
Old 01-11-2017, 02:16 AM
 
xcartdev2 xcartdev2 is offline
 

Advanced Member
  
Join Date: Nov 2011
Posts: 43
 

Default Re: Hide products from a category in search results only

Thanks cflsystems but I realised this would only work if the main category of the product to be hidden was 273.

A better way I found (for anyone else who finds this thread) is to flush out the products after the database query has been completed. Like this:

PHP Code:
// collect productids of products from categoryid 273 to flush from search results
                
if ($cat == "") { // only if this is a search result, not a category page
                
$get_products=mysql_query("SELECT productid FROM xcart_products_categories WHERE categoryid='273'");    
                
                while (
$row_products mysql_fetch_array($get_products)) {
                    
$products_arr[]=$row_products['productid'];
                    }
                    
                foreach (
$products as $k => $v) {
                    if (
in_array($products[$k]['productid'], $products_arr)) {
                        unset(
$products[$k]);
                        
$total_items=$total_items-1;
                        }
                    }    
                } 
__________________
Verion 4.7.12
Reply With Quote