Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seach results


iLLuSiOnS

Recommended Posts

Hi, my (basic) search results, are really bugging me.

 

When I search lets say: 324

it will show me results with products that have the number 324 in it, like 2324, or 6324 and even 24 or 32.

 

I want it to show only exact matches, so If someone searches 324, it will only show products "324"

 

How can I fix this without having to put " or [ or use the advanced search.

 

Thanks

Link to comment
Share on other sites

In catalog/advanced_search_result.php, find the following:

 

          $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";

and replace it with:

 

          $where_str .= "(pd.products_name = '" . tep_db_input($keyword) . "' or p.products_model = '" . tep_db_input($keyword) . "' or m.manufacturers_name = '" . tep_db_input($keyword) . "'";

 

That will get you only the exact result for products name, products model, or manufacturer's name. If you don't want the exact result for any of those three, don't make the changes for the ones you don't want.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 3 weeks later...

In catalog/advanced_search_result.php, find the following:

 

          $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";

and replace it with:

 

          $where_str .= "(pd.products_name = '" . tep_db_input($keyword) . "' or p.products_model = '" . tep_db_input($keyword) . "' or m.manufacturers_name = '" . tep_db_input($keyword) . "'";

 

That will get you only the exact result for products name, products model, or manufacturer's name. If you don't want the exact result for any of those three, don't make the changes for the ones you don't want.

 

Regards

Jim

 

 

I did this, but now NO search results are returned, no matter what I search for. To make things a little bit more clear, I have products like "14k diamond ring 1230" and "18k diamond ring 1230" and "14k diamond ring 1330" and "18k diamond ring 1330"

 

I dont want the user to have to search "14k diamond ring" or "18k diamond ring" just want them to be able to search 1230 and find both the 14k and 18k, the problem I am having now is that when someone searchs 230 the 1230 will show as a result, and I dont want that.

 

Thanks

Link to comment
Share on other sites

The try it this way...

 

$where_str .= "(pd.products_name like '% " . tep_db_input($keyword) . "' or p.products_model like '% " . tep_db_input($keyword) . "' or m.manufacturers_name like '% " . tep_db_input($keyword) . "'";

Community Bootstrap Edition, Edge

 

Avoid the most asked question. See How to Secure My Site and How do I...?

Link to comment
Share on other sites

The try it this way...

 

$where_str .= "(pd.products_name like '% " . tep_db_input($keyword) . "' or p.products_model like '% " . tep_db_input($keyword) . "' or m.manufacturers_name like '% " . tep_db_input($keyword) . "'";

YOU ARE THE MAN!!! Ive been tryin to figure that out for ages. Thanks a lot mate.

Link to comment
Share on other sites

Contrary to others beliefs, lol.... but you will find most here are always willing to lend a hand.

I know. I have been a member for 7 years, been using oscommerce for longer, I usually never ask questions, no have problems, but once in a while I get small issues like this, and most people are willing to help, but I just guess its hard to get peoples attention, sometimes I have to repost a few times. But I got lucky this time, thanks again

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...