• Hello,

    When I search for an item sku example “A13375101B1A1” it shows as expected, but if I remove “B1” for example, there are no results.

    How do I make it where partial sku searches will still populate results?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    For Releavnssi, A13375101B1A1 and A13375101A1 are two completely different words. It’s the same as saying that when you search for “populate” you get the results you expect but when you remove “la” and search for “popute”, you get no results. You wouldn’t, as “popute” is not a word on your site. It’s the same thing with the SKU codes; to Relevanssi, they function exactly as any other word would.

    If your SKU codes have some inner logic where it makes sense to search for them without some parts inside them, you need to make sure Relevanssi indexes them in all possible ways. If it’s ok to remove the B1 inside the code, you must have Relevanssi index the code both ways, as A13375101B1A1 and A13375101A1. That way the product can be found with both codes.

    You can use the relevanssi_content_to_index filter hook to add content to your posts. A filter function on that hook that reads in the SKU code, creates all the valid permutations of it and has Relevanssi index them would solve this problem.

    The function would look like this:

    add_filter( 'relevanssi_content_to_index', function( $content, $post_object ) {
      $sku = get_post_meta( $post_object->ID, '_sku', true );
      if ( $sku ) {
        // Create the SKU permutations here
        $content .= ' ' . $sku_permutation_1;
        $content .= ' ' . $sku_permutation_2; // etc...
      }
      return $content;
    }, 10, 2 );
    Thread Starter acoderjones91

    (@acoderjones91)

    I greatly appreciate the timely response, Mikko!

    However, after adding the relevanssi_content_to_index filter you provided into the functions.php, but still getting the same results when searching A13375101A1.

    Any additional assistance would be appreciated!

    Best,
    Anthony

    Plugin Author Mikko Saari

    (@msaari)

    How did you modify the function to handle your SKU permutations? In itself, the function I gave you does nothing because it’s missing the SKU manipulation logic. I couldn’t add that in, because I don’t know how the logic in your SKUs works.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘No results when missing values from SKU’ is closed to new replies.