Fixing the Search

I know this topic has been widely discussed in the past, but I would like to know what the current best solution to the cs cart search problem is.



Are you guys using a third-party site-search?



Tweaking the CS Cart search?



Unless my customers search by part number, they'll never find anything on my site.



The default is to search for “any of these words” in every field.



I've tried to change the search.tpl in skins/{your_skin}/customer/common_templates/


```php









{hook name="search:additional_fields"}{/hook}
{$lang.search}:
{if !$settings.General.search_objects}

- {$lang.all_categories} -
{foreach from=0|fn_get_subcategories item="cat"}
{$cat.category|escape:html|truncate:100:"...":true}
{/foreach}

{/if}
{strip}

{if $settings.General.search_objects}
{include file="buttons/go.tpl" but_name="search.results" alt=$lang.search}
{else}
{include file="buttons/go.tpl" but_name="products.search" alt=$lang.search}
{/if}
{if !$hide_advanced_search}
{$lang.advanced_search}
{/if}
{/strip}

```

But there is some other force at work preventing these changes from taking effect. All searches include all fields and my users get back useless lists of hundreds of results.

What's the best way to set up search on a CS Cart site?

Have you utilized the “Search words” in product details? What I input into the “Search words” field is “Manufacturer MPN Product code Product name”.

Yeah, I started out using relevant terms in the “Search Words” field, but quickly found that it didn't matter because all the fields are returned on search. So I stripped it down to just the individual SKUs. We only sell stuff that we manufacture, so there's no point in putting that.



My problem is that the searches are returning too much data. I can't figure out how to make it only read from the pname and pkeywords fields.

[quote name='plinkplink' timestamp='1328136433' post='130433']My problem is that the searches are returning too much data. I can't figure out how to make it only read from the pname and pkeywords fields.

[/quote]



They do the same thing with the Quick search addon. Talk about double the size of your database real quick. I edited the addon to only cache the Search words.

Oh, maybe that's my problem. I've got the quick search addon uninstalled. What's the difference between them?

Not that big of a deal. Just a quick search drop down that occurs when customer begins typing in the search box.

Oh yeah, I think turned it off because it was conflicting with some other javascript.



Does anyone know how to fix my search problem? What's causing it to ignore the search.tpl and scrape every single field for every product and page?

Might be too obvious, but did you clear cs-carts cache?

Yeah, I'm constantly clearing that thing… But any ideas are good ideas at this point.

Here's what the URL looks like after a serach:



MYDOMAIN.COM/?subcats=Y&status=A&pshort=N&pfull=N&pname=Y&pkeywords=Y&search_performed=Y&q=MY_SEARCHWORD&dispatch=search.results&x=0&y=0

Maybe it's been overwritten by a hook? Did you go into design mode to check which tpl file it's using?

I didn't think of that. Checking the .tpl via design mode led me to realize that it's the top_search.tpl that I'm worried about. Duh.



I commented out the hook, changed the perimeters and got the same results: it's searching all fields.



The weird thing is the url that the search returns has changed to reflect the tpl settings, but the results are the same.



http://www.unikeep.com/?subcats=Y&status=A&pshort=N&pfull=N&pname=Y&pkeywords=Y&search_performed=Y&q=MY_SEARCH&x=0&y=0&dispatch=search.results




What do you suppose “search_performed” means?

Have you tried this? [url=“CS-Cart Documentation — CS-Cart 4.15.x documentation”]CS-Cart Documentation — CS-Cart 4.15.x documentation

Oh wow. That was really close to what I needed. Except I was trying to change “top search” not “quick search” and I needed to set the opposite effect.



It was in that same file: core/fn.catalog.php around line 3180. Right below the where Knowledge base suggested the additional code I just changed 'any' to 'all' and it seems to have worked.



Man, am I glad you ran across that. I would have never found it.



Thanks!

[quote name=‘plinkplink’ timestamp=‘1328500533’ post=‘130661’]



Man, am I glad you ran across that. I would have never found it.



Thanks!

[/quote]



Glad that helped. The knowledge base actually does have some helpful stuff in it :)