You are here:  » Exclude products in a search results possible?


Exclude products in a search results possible?

Submitted by twdesigns on Wed, 2013-04-03 15:50 in

This may not be possible but what I am trying to do is exclude products from appearing in a search result.

Example:
If I search for "Bane T-shirts" I not only get bane t-shirts but also Lebanese T-shirts returned. I would like to exclude the Lebanese results since the search link I am using is related to Comic Heros.

Is there commands such as "-lebanese," or etc that I can use.

Submitted by support on Wed, 2013-04-03 16:00

Hi,

If you're linking to a specific query then negative terms could easily be included by way of a $priceWhere clause. In pto_search.php, look for the following code at line 157:

$html = "";

...and REPLACE with:

switch($q)
{
  case "Bane T shirts":
    $priceWhere .= " AND name NOT LIKE '%Lebanese%' ";
    break;
  case "Other Direct Search":
    $priceWhere .= " AND name NOT LIKE '%OtherExclusion%' ";
    break;
}
$html = "";

(at this point in the code, $q is "normalised", (non text / extended characters removed) so an input of "T-shirt" would be just "T shirt" here)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by twdesigns on Thu, 2013-04-04 00:52

Hey David,

Thank you for the code sample. It will come in handy. The issue I'm running in to is I have around 609 search queries for one section / category. I attempted to create a new custom category then add a list or products to it by filtering out, for example, Lebanese but it doesn't appear to work that way or I am doing something wrong?

I really didn't think there was an easy solution but I had to ask :)

Submitted by support on Thu, 2013-04-04 07:50

Hi,

If you wanted to override the category for a small number of products, don't forget that Product Mapping allows you to override the category for a mapped product, regardless of what category it appears under in the feed. You don't need to use the actual "Alternatives" functionality of Product Mapping - that can remain blank, so to override the category for a single product, simply create a new Product Mapping with the name is it currently appears on your site, and enter your custom category on the configuration page for the mapping.

However, what may be slightly more convenient, especially if you wish to map a number of products to your custom category would be a simple mod that quite a few users work with which is to extend the Category Mapping functionality so that it considers product name also, which is described in this thread on PriceTapestry.com.

This way, you could create a custom category (as I think you are doing already) and then in the Alternatives box on the configuration page, enter exact match terms (beginning with "=") but referring to products instead of categories (it will still work as normal by referring to categories of course).

Because the Category Mapping helper only looks at categories by default, an easy way would be to open a dummy Product Mapping configuration page in a new tab / window, use that to locate the products you wish to include in your custom category and add them as exact matches, then copy / paste the contents of the Alternatives box into the alternatives box for your new custom Category Mapping...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com