• Resolved Manu-PB

    (@manu-pb)


    Hi,
    I use Relevanssi to search inside woocommerce the “product attributes” custom field.
    Indexing is OK, with _product_attributes as custom field.
    But the search excerpt is broken – replaced by the_content().
    The reason is that the content of the custom field is an array of array, and the function relevanssi_get_custom_field_content($post_id) does not manage it ($value is set to “Array” instead of the field value).
    Can you help?
    Thanks

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

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

    (@msaari)

    add_filter( 'relevanssi_custom_field_value', 'rlv_fix_array_values', 10 );
    function rlv_fix_array_values( $values ) {
        $fixed_values = array();
        foreach ( $values as $value ) {
            $fixed_value = '';
            if ( is_array( $value ) ) {
                foreach ( $value as $row ) {
                    if ( is_array( $row ) ) {
                        $fixed_value .= ' ' . implode( ' ', $row );
                    } else {
                        $fixed_value .= ' ' . $row;
                    }
                }
            } else {
                $fixed_value = $value;
            }
            $fixed_values[] = $fixed_value;
        }
        return $fixed_values;
    }

    If you add this to your theme functions.php, does that fix the problem?

    Thread Starter Manu-PB

    (@manu-pb)

    Works great, thanks !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woocommerce _product_attributes’ is closed to new replies.