• Hello,

    I try to ignore space in the search bar. For example “TRIO290” I see only the correct category if I type “TRIO 290”. I tried multiple snippets. Nothing work. I use PRO version. All other snippets from documentation works well.

    add_filter( 'aws_search_terms', 'my_aws_search_terms' ); function my_aws_search_terms( $s ) { $new_s = implode( '', $s ); $s[] = $new_s; return $s; }

    add_filter( 'aws_special_chars', 'my_aws_special_chars' ); function my_aws_special_chars( $chars ) { unset( $chars[array_search( '&amp ;',$chars )] ); unset( $chars[array_search( '&',$chars )] ); return $chars; }

    Any ideas please ?

    • This topic was modified 1 year, 9 months ago by imloic.
Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    So, as I understand, you see search results for search query “TRIO290”?but not for “TRIO 290”. Is that correct?

    Regards

    Thread Starter imloic

    (@imloic)

    Yes ! I need to ignore the space in order to have same results for TRIO290 and TRIO 290

    Thx

    Plugin Author ILLID

    (@mihail-barinov)

    Please try to use following code snippet:

    add_filter( 'aws_search_terms', 'aws_search_terms' ); 
    function aws_search_terms( $terms ) { 
        if ( $terms ) { 
            foreach ($terms as $term) { 
                preg_match_all('/([0-9]+|[a-zA-Z]+)/',$term,$matches); 
                if ( ! empty( $matches ) ) { 
                    $terms = array_merge( $terms, $matches[0] ); 
                } 
            } 
        } 
        return $terms; 
    }

    You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.

    Also, after adding this code you will need to go to the plugin settings page and click the ‘Clear cache’ button.

    Regards

    Thread Starter imloic

    (@imloic)

    Hi. Thx for reply. This code does nothing

    hitmusic.eu

    Thanks

    Plugin Author ILLID

    (@mihail-barinov)

    Did you cleared the plugin cache after adding this code snippet?

    Thread Starter imloic

    (@imloic)

    Yes sir ! and I even reindexed the table

    Plugin Author ILLID

    (@mihail-barinov)

    In this case please additionally add following code:

    add_filter( 'aws_extracted_terms', 'my_aws_extracted_terms' );
    
    function my_aws_extracted_terms( $str_array ) {
    
    $new_terms = array();
    
    if ( $str_array && is_array( $str_array ) && ! empty( $str_array ) ) {
    
    foreach ( $str_array as $str_term => $str_num ) {
    
    if ( preg_match( "/\b[\d]+([^\d\W]+)[\d]+\b/i", $str_term, $matches ) ) {
    
    $new_terms[] = str_replace( $matches[1], '', $str_term );
    
    }
    
    }
    
    }
    
    if ( $new_terms ) {
    
    foreach( $new_terms as $new_term ) {
    
    $str_array[$new_term] = 1;
    
    }
    
    }
    
    return $str_array;
    
    }

    And reindex table one more time.

    Thread Starter imloic

    (@imloic)

    Hi ! This code don’t work too. Sorry

    Thread Starter imloic

    (@imloic)

    Just to be precise, I want it to work for a category name and not just the product name. For the product name the code works fine!

    Plugin Author ILLID

    (@mihail-barinov)

    Strange, because this code must work and for categories names too.

    To make things clear – it is not working for categories archive pages search or for products search via categories names?

    Regards

    Thread Starter imloic

    (@imloic)

    Hello ! The search for products is done via the category names

    You can try on HITMUSIC.EU
    TRIO290 -> NOTHING
    TRIO 290 -> the categories appear.

    I would like to see the category TRIO 290 when I type TRIO290.

    Thx. Otherwise the plugin is great. Congratulations for your work!

    Plugin Author ILLID

    (@mihail-barinov)

    So you are using both code snippets. Right?

    Also please tell me – this TRIO 290?category is a parent or child category?

    Thread Starter imloic

    (@imloic)

    Yes ! I try all snippets. TRIO 290 is a child

    Thread Starter imloic

    (@imloic)

    I tried all snippets. TRIO 290 is a child.

    Thread Starter imloic

    (@imloic)

    Do you have more info please ?

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Ignore space in the search bar’ is closed to new replies.