Search order

  • Posts: 63
  • Thank you received: 3
11 years 7 months ago #98246

Hi there,

I'm having a slight problem with searches on my website:

www.wslr.co.uk/index.php/resources-catalogue

Question 1

The search is returning partial words - for instance if I do a text search for our planet, anything with the "our" contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.

I have the text search looking in product code, product keywords, product name, and product description.

Is there a way to make the search only see whole words?

Question 2

I would like to return the products in order of priority and I've set up a custom field named "order" and this will be 1,2,3 or 4

I'd like all order 1 to come up first, then order 2, and so on.

I've set the Default parameters for products ordering field to "order" which is my cistom field, but it doesn't seem to work in the way I expected.

How can I set all searches to return the product in order 1,2,3,4 etc

Hope this makes sense,

ian

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 7 months ago #98383

Hi,

1. You can change the line:
$list[]=' b.'.$column.' LIKE \'%'.hikashop_getEscaped($term, true).'%\' ';

to:
$list[]=' b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).' %\' ';

in the file administrator/components/com_hikashop/classes/filter.php to make sure there is a space before and after the words but then if the word is the first word of the field and thus doesn't have a space before or if if it has a dot or a comma after.

That might be possible with a more complex condition like that :
$list[]=' (b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \''.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).',%\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).'.%\')';
but it's still not perfect...

2. Change the "ordering field" in the hikashop options of your menu via the menu Display->Content menus and that should do it.

The following user(s) said Thank You: ians

Please Log in or Create an account to join the conversation.

  • Posts: 63
  • Thank you received: 3
11 years 7 months ago #98389

Thanks Nicolas,

For the search - I'll try changing the code as you suggest.

However, I was wondering if there could be another option?

If you include some words in commas in Google - like "our planet" it would find matching whole words. Is there a way to make this happen in HikaShop? This would also solve my problem.

Yours,

ian

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 7 months ago #98521

That's not possible.

We're simply using the LIKE feature of mysql to search for the text in the database. Google has a powerful search algorithm which is much much much more complex than what can be done with that LIKE feature.

Please Log in or Create an account to join the conversation.

  • Posts: 63
  • Thank you received: 3
11 years 7 months ago #98534

Hi Nicolas,

thank you for your help.

I applied the more complex condition and it seems to work.

I'll let you know how I get on with it.

You are a genius!!

Thanks

Ian

Please Log in or Create an account to join the conversation.

  • Posts: 63
  • Thank you received: 3
11 years 7 months ago #99723

Hi Nicolas,

Many thanks for helping with the search in filters.

I've added the code you suggested and it has made a big difference:

$list[]=' (b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \''.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).',%\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).'.%\')';
but it's still not perfect...

It's not working quite as expected. If the product has a single word - no space before or after, it still doesnt show up in the search.

if i search for "dragonslayer" for instance which is the only word in the title - doesnt come up.

or if I search for it's product code "FD0810" it doesn't come up

product link is here:

www.wslr.co.uk/index.php/resources-catal...ow/1789-dragonslayer

Search page is here:

www.wslr.co.uk/index.php/resources-catalogue

do you have any suggestions?

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 7 months ago #99838

Hi,

It's because you have some missing tests, like the search string itself:

$searchEscaped = hikashop_getEscaped($term, true);
$list[]=' (b.'.$column.' LIKE \'% '.$searchEscaped.' %\' OR b.'.$column.' LIKE \''.$searchEscaped.' %\' OR b.'.$column.' LIKE \'% '.$searchEscaped.',%\' OR b.'.$column.' LIKE \'% '.$searchEscaped.'.%\' OR b.'.$column.' LIKE \''.$searchEscaped.'\')';

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 11 years 7 months ago by Jerome.

Please Log in or Create an account to join the conversation.

  • Posts: 63
  • Thank you received: 3
11 years 7 months ago #99921

Hi Nicolas,

Ah, I see.

I just tried adding that code but it broke the shop (shop wouldn't load), so i must have added it to the wrong place.

Please could you clarify where the 2 bits of code go?

I replaced this:

$list[]=' b.'.$column.' LIKE \'%'.hikashop_getEscaped($term, true).'%\' ';

with this:

$list[]=' (b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \''.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).',%\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).'.%\')';

and added this to it:

$searchEscaped = hikashop_getEscaped($term, true);
$list[]=' (b.'.$column.' LIKE \'% '.$searchEscaped.' %\' OR b.'.$column.' LIKE \''.$searchEscaped.' %\' OR b.'.$column.' LIKE \'% '.$searchEscaped.',%\' OR b.'.$column.' LIKE \'% '.$searchEscaped.'.%\' OR b.'.$column LIKE \''.$searchEscaped.'\')';

Appreciate your help,

Ian

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 7 months ago #100260

Hi,

I have fix a missing quote in my previous post.
Please recopy it, it should be better.

Regards,
Jerome


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.076 seconds
Powered by Kunena Forum