• Resolved joshuabl

    (@joshuabl)


    I’ve been struggling to index the taxonomy type ‘product_cat’. I’ve selected it within the indexing settings, turned on indexing for taxonomy terms, rebuilt the index multiple times, increased the weight for ‘product_cat’, and tried several code snippets I found on the Relevanssi site included below.

    add_filter( 'relevanssi_content_to_index', 'rlv_parent_categories', 10, 2 );
    function rlv_parent_categories( $content, $post ) {
    	$categories = get_the_terms( $post->ID, 'product_cat' );
    	if ( is_array( $categories ) ) {
    		foreach ( $categories as $category ) {
    			if ( ! empty( $category->parent ) ) {
    				$parent = get_term( $category->parent, 'product_cat' );
    				$content .= $parent->name;
    			}
    		}
    	}
    	return $content;
    }
    add_filter( 'relevanssi_modify_wp_query', 'rlv_include_product_cat' );
    function rlv_include_product_cat( $query ) {
    	if ( isset( $query->query_vars['product_cat'] ) ) {
    		$query->query_vars['tax_query'][] = array(
    			'taxonomy' => 'product_cat',
    			'field'    => 'slug',
    			'terms'    => $query->query_vars['product_cat'],
    			'include_children' => false,
    		);
    	}
    	return $query;
    }

    I’m out of ideas at this point. Could someone give me some advice?

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

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

    (@msaari)

    Which is the problem here, indexing or searching?

    Is the problem that you can’t get the product_cat indexed for the products, or that it is indexed, but the search doesn’t find it?

    The search does seem to work. The MSH4024RE Inverter Parts category has five posts, and searching for “MSH4024RE Inverter Parts” finds those five posts. Looks like the product category searching is working as expected.

    If not, please elaborate on what the problem here is.

    Or is the problem that you want the product_cat category archives to show up in the search results, not just products in the category? That does require Relevanssi Premium; it is not possible with the free version of Relevanssi.

    Thread Starter joshuabl

    (@joshuabl)

    I’m looking to index the product_cat category archive pages and I do have Relevanssi Premium.

    Plugin Author Mikko Saari

    (@msaari)

    I’m not allowed to provide Premium support here. Please use the Premium support form here.

    When contacting me through the support form, please share a screenshot of your indexing settings if possible. Thanks!

    Thread Starter joshuabl

    (@joshuabl)

    Ok done

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Indexing product_cat’ is closed to new replies.