Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 30
  1. #11
    Join Date
    Apr 2011
    Posts
    5
    Plugin Contributions
    0

    Default Re: Improving search results

    Quote Originally Posted by fontaholic View Post
    rob, thank you for this code. i'm hoping to get it to work. i did the text indexing and put the code changes above into my header_php.php file, but it's not working (as far as i can tell). you reference something called 'robs_keywords'... how do i define that for my own site? ultimately i'm hoping to have this sort search results by product category, then products name if possible. do you think that is possible? thanks!
    SWEEEEEEEET!!!! that sorted it right out. top notch!!!

  2. #12
    Join Date
    Apr 2011
    Posts
    5
    Plugin Contributions
    0

    Default Re: Improving search results

    Nice one! that sorted my search out loads; there's still a few stragglers here and there but it's infinitely better! thanks man i really appreciate that!

  3. #13
    Join Date
    Dec 2009
    Posts
    55
    Plugin Contributions
    0

    Default Re: Improving search results

    I just performed the mod on my 1.3.9h store and it works great! I just need to do the additional modification to the mysql config file to account for the 3 letter words. Thanks for posting the code!
    Vu Nguyen | Multimedia Developer & Webmaster
    Robotics Academy/Robomatter
    Robomatter Robotics Education Store

  4. #14
    Join Date
    Dec 2012
    Posts
    30
    Plugin Contributions
    0

    Default Re: Improving search results

    trying to add full text using phpmyadmin but it doesnt have that option, its grayed out. anyone else have this issue?

  5. #15
    Join Date
    Apr 2019
    Posts
    168
    Plugin Contributions
    0

    Default Re: Improving search results

    Quote Originally Posted by madmouse View Post
    Ok, I finally sussed this. I now have relevant ranked results using the built in ZenCart search. It's a bit of a hack (modifying a core file) but I don't know how to do it properly using the notifers, etc. But it is a very simple hack. It uses the full text searching capabilities built in to mySQL to rank each result and then it sorts the results by that rank. I've done lots of test searches on my site and it really does work well.

    Step one: enable full text indexing
    Using phpMyAdmin, go to the structure of products_description. On the row for products_name, look at the end of the row and press the T icon (if you hover the tooltip is Fulltext). Now do the same for products_description.

    Step two: edit the code in includes/modules/pages/advanced_search_result/header_php.php

    Around line 219, add the code in red. The commented out line above is nothing to do with me, it was already commented out.

    Code:
    // Notifier Point
    $zco_notifier->notify('NOTIFY_SEARCH_SELECT_STRING');
    
    
    //  $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";
    
    // FullText Ranking code by Rob - www.funkyraw.com
    $from_str = ",  MATCH(pd.products_name) AGAINST(:keywords) AS rank1, MATCH(pd.products_description) AGAINST(:keywords) AS rank2 ";
    $from_str = $db->bindVars($from_str, ':keywords', stripslashes($_GET['keyword']), 'string');
    //end FullText ranking code
    
    $from_str = "FROM (" . TABLE_PRODUCTS . " p
                 LEFT JOIN " . TABLE_MANUFACTURERS . " m
                 USING(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c )
                 LEFT JOIN " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd
                 ON mtpd.products_id= p2c.products_id
                 AND mtpd.language_id = :languagesID";
    and change the line immediately below what you have added to:
    Code:
    $from_str .= "FROM (" . TABLE_PRODUCTS . " p
    (just added a . before the = sign)



    Now find this line at around line 415
    Code:
    $order_str .= " order by p.products_sort_order, pd.products_name";
    and change it to:
    Code:
    $order_str .= " order by rank1 DESC, rank2 DESC, p.products_sort_order, pd.products_name";
    And you're done. Make sure you test before going live. It will fail with errors if you haven't first enabled the full text indexing. Hope it helps someone. And if anyone wants to use the code to create a proper module then please go ahead.

    Rob
    This trick also works on 1.57c. Thanks!

    But I did notice that sometimes my screen will auto scroll down several rows. It only happens on my PC, not on my phone. I did some tests and it looked like that it is related to jscript_onload_helper.php under the same folder. I deleted that file and it worked properly. It doesn't generate any log files or warning.
    Last edited by njcyx; 5 Aug 2021 at 12:54 AM.

  6. #16
    Join Date
    Apr 2019
    Posts
    168
    Plugin Contributions
    0

    Default Re: Improving search results

    This trick also works on zc1.58. Thanks!

    But the file has been moved. This modification should be applied to the following file instead.

    \includes\modules\pages\search_result\header_php.php

    jscript_onload_helper.php file is gone as well. I cannot find this file and I cannot find function onloadFocus() in any files in zc1.58 now. I didn't notice the "auto scroll" issue I mentioned in my last post anyway.

  7. #17
    Join Date
    Jul 2009
    Posts
    14
    Plugin Contributions
    1

    Default Re: Improving search results

    Using Rob's full-search technique really improved the search results on our web site. I wrote a blog post a while back on how I implemented it for 1.5.7. I tweaked it a little for slightly better results and added a field so that you can specify additional text to search that isn't displayed to the customer:

    https://jonrocket.com/zencart/2021/0...earch-results/

  8. #18
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,427
    Plugin Contributions
    11

    Default Re: Improving search results

    Quote Originally Posted by jadebox View Post
    Using Rob's full-search technique really improved the search results on our web site. I wrote a blog post a while back on how I implemented it for 1.5.7. I tweaked it a little for slightly better results and added a field so that you can specify additional text to search that isn't displayed to the customer:

    https://jonrocket.com/zencart/2021/0...earch-results/
    for anyone thinking about doing this, i think it is a MAJOR mistake. granted this is only my opinion, but still...

    as the blog post says in it's preface:

    "The method I describe here involves directly modifying Zen Cart core files. Generally, it isnít a good idea to modify the core files of an application since it makes upgrading more difficult and error-prone...."

    i agree with the preface that searching on zen-cart was not ideal... which is why there has been some MASSIVE overhaul of said searching in v158. i should know... i coded most of it... and the initial merge on my PR on searching was over 2 years ago (or something like that). and i have waited for this code to be released to the ZC community. which is now is. and part of it can be seen here:

    https://github.com/zencart/zencart/b....php#L160-L210

    in fact, i saw that my code was being re-used on the search modal in the bootstrap template.

    now, could this be improved? no doubt; i think most code can be improved.

    but coming onto the ZC forum and promoting code that modifies the ZC core is not my idea of supporting the community. if you think your code is so great, where is the PR on github? why not use notifiers?

    i think anyone who is thinking about changing all of those core files should think long and hard.

    and if you really want better searching on the customer side, i would look at this plugin:

    https://github.com/marco-pm/zencart_instantsearch

    finally, the new search functions that are now merged into the v158 core are used throughout the repository; including on the admin side.

    at some point, i hope to write something up in the docs.

    second finally: i will look close at the blog post, and perhaps consider adding some of the code to the ZC core. which i think better supports the community. or maybe @jadebox can do it.

    best.
    mxWorks now has premium plugins
    are you using square? have you shown any appreciation with cake on venmo or on paypal?
    called the savior by the chief bottle washer...

  9. #19
    Join Date
    Jul 2009
    Posts
    14
    Plugin Contributions
    1

    Default Re: Improving search results

    I shared something I found useful and gave a warning about why it mignt not be the best way to accomplish the goal. I documented it for my own reference and thought it might be useful to other users of Zen Cart and to the developers.

    I didn't intend to disparage you or any others working on Zen Cart since I really appreciate the work that has gone into it. I would have suffered though the effort to convert to another shopping cart if the 1.5.x upgrade had not been such an improvement over the 1.3.x version I was using.

    You are quite welcome to use any of the code or ideas from the blog post if you find them useful. I am willing to help but free time is in short supply for me until I finally decide to retire.
    Last edited by jadebox; 28 Oct 2022 at 01:40 PM.

  10. #20
    Join Date
    Apr 2019
    Posts
    168
    Plugin Contributions
    0

    Default Re: Improving search results

    Thanks for all the inputs.

    Instant search plug-in mentioned by @carlwhat is great. However, it doesn't search the description by the latest published version (v2.1.0). Its author mentioned adding description search could slow down the site which makes senses to me. I don't want to make my site slower again...

    https://www.zen-cart.com/downloads.php?do=file&id=1336

    The trick mentioned in this thread is not ideal, but it works for description search and it is not difficult to modify the code.

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. v154 Improving search box results on main page
    By cahoca in forum General Questions
    Replies: 2
    Last Post: 24 Jan 2016, 04:26 PM
  2. Improving Search Speed
    By jmcdougal in forum General Questions
    Replies: 0
    Last Post: 28 Jan 2011, 06:27 PM
  3. Improving Site Search
    By mutualadvantage in forum General Questions
    Replies: 1
    Last Post: 18 Feb 2008, 10:47 PM
  4. Replies: 8
    Last Post: 5 Dec 2006, 10:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR