Results 1 to 10 of 32

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,908
    Plugin Contributions
    13

    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.
    author of square Webpay.
    mxWorks now has Apple Pay and Google Pay. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  2. #2
    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.

  3. #3
    Join Date
    Apr 2019
    Posts
    338
    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.

  4. #4
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,826
    Plugin Contributions
    31

    Default Re: Improving search results

    Since the thread title is Improving Search Results perhaps this warrants a mention:

    https://github.com/lat9/prioritize_matching_names
    Steve
    github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

  5. #5
    Join Date
    Jul 2009
    Posts
    14
    Plugin Contributions
    1

    Default Re: Improving search results

    Quote Originally Posted by torvista View Post
    Since the thread title is Improving Search Results perhaps this warrants a mention:

    https://github.com/lat9/prioritize_matching_names
    That's a good update since it makes products with the search keywords in the product name appear before ones just matching words in the description. A slight enhancement would be to have product names that begin with the keywords listed first. I haven't tested it, but something like the following might work:

    Code:
    public function update(&$class, $eventID) 
        {
            switch ($eventID) {
                case 'NOTIFY_SEARCH_SELECT_STRING':
                    global $db, $keywords, $select_str;
                    if (!empty($keywords) && zen_parse_search_string(stripslashes($_GET['keyword']), $search_keywords)) {
                        $in_name_select1 = '';
                        $in_name_select2 = '';
                        foreach ($search_keywords as $current_keyword) {
                            switch ($current_keyword) {
                                case '(':
                                case ')':
                                case 'and':
                                case 'or':
                                    $in_name_select1 .= " $current_keyword ";
                                    $in_name_select2 .= " $current_keyword ";
                                    break;
    
                                default:
                                    $in_name_select1 .= "pd.products_name LIKE '%:keywords'";
                                    $in_name_select1 = $db->bindVars($in_name_select1, ':keywords', $current_keyword, 'noquotestring');
                                    $in_name_select2 .= "pd.products_name LIKE '%:keywords%'";
                                    $in_name_select2 = $db->bindVars($in_name_select2, ':keywords', $current_keyword, 'noquotestring');
                                    break;
                            }
                        }
                        $select_str .= ", IF ($in_name_select1, 1, 0) AS in_name1, IF ($in_name_select2, 1, 0) AS in_name2 ";
                        $this->order_by = ' in_name1 DESC, in_name2 DESC,';
                    }        
                    break;
    
                case 'NOTIFY_SEARCH_ORDERBY_STRING':
                    global $listing_sql;
                    $listing_sql = str_ireplace('order by', 'order by' . $this->order_by, $listing_sql);
                    break;
    
                default:
                    break;
            }

  6. #6
    Join Date
    Apr 2019
    Posts
    338
    Plugin Contributions
    0

    Default Re: Improving search results

    Hi @jadebox, I just tried your modified code in zc1.58. Unfortunately, it doesn't make any difference on my search result (not work). Actually the original code from github doesn't make any difference neither. Not sure why...I have changed "header_php.php" file back to the default before the test. No log file is received during my test. The original code is based on zc 1.53 though.

    For your mentioned code, I suspected you want to rank by the product name at first, then product description, correct? So your following line below

    $in_name_select2 .= "pd.products_name LIKE '%:keywords%'";

    It should be changed to the following, if I'm correct.

    $in_name_select2 .= "pd.products_description LIKE '%:keywords%'";

    It doesn't work no matter I changed the line above or not...
    Last edited by njcyx; 9 Nov 2022 at 07:01 PM.

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

    Default Re: Improving search results

    Quote Originally Posted by njcyx View Post
    Hi @jadebox, I just tried your modified code in zc1.58. Unfortunately, it doesn't make any difference on my search result (not work). Actually the original code from github doesn't make any difference neither. Not sure why...I have changed "header_php.php" file back to the default before the test. No log file is received during my test. The original code is based on zc 1.53 though.

    For your mentioned code, I suspected you want to rank by the product name at first, then product description, correct? So your following line below

    $in_name_select2 .= "pd.products_name LIKE '%:keywords%'";

    It should be changed to the following, if I'm correct.

    $in_name_select2 .= "pd.products_description LIKE '%:keywords%'";

    It doesn't work no matter I changed the line above or not...
    No, I wanted it to sort products that have names that start with the keywords before products that just have the keyword in the name. The first "like" returns True for product names starting with the keywords (:keyword%). The second returns True for product names which include the keywords anywhere (%: keywords%). Using "DESC" causes tbe LIKEs that return True to be listed before the ones that are False.

    So, if your keyword is "Red" then a product called "Red Rider BB Gun" will be listed before "Daisy Red Rider BB Gun."
    Last edited by jadebox; 9 Nov 2022 at 07:30 PM.

 

 

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

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