shopp_boolean_search

filters the list of keywords to be used in the catalog boolean Full-Text terms search query.

add_filter( 'shopp_boolean_search', [callback] )

@param string $keywords a list of keywords to be used in the boolean search query.

Description

filters the list of keywords to be used in the catalog boolean Full-Text terms search query.

The Shopp search engine does a number of processes on this filter including:
code/markup filtering, currency character filtering, accented character filtering, lower-case filtering, stemming, and normalizing.

Execute your filter late if you want to alter the keywords after Shopp has processed them, and early if you want to modify the more primative version of the search keywords.
This filter is useful for doing your own advanced processing on searches before a search query.

Be aware that short-words, less than the ft_min_word_len MySQL Server System parameter will always be ignored by MySQL. This defaults to 4 characters on most servers. Contact your hosting provider to see if this can be lowered to 3 characters if your products consistently require 3 character searches (example: “bed”). This filter will not help with this limitation.

Example

// register filter callback late
add_filter('shopp_boolean_search', 'my_boolean_keywords_filter', 99);

// create filter function to force boolean AND in search
function my_boolean_keywords_filter( $keywords ) {
    $tokens = array();

    // split string up into each search keyword
    $token = strtok($keywords,' ');
    while ( $token ) {
        // if the first character is not '+'
        if ( "+" != substr($token, 0, 1) )
            $tokens[] = '+'.$token; // force boolean AND
        else $tokens[] = $token;
        strtok(' ');
    }

    return implode(' ', $tokens);
}

See Also

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar