WPFTS Pro Main Site WPFTS Community Forum
    • Recent
    • Tags
    • Popular
    • Register
    • Login
    1. Home
    2. Atrix
    Get WPFTS Pro today with 25% discount!
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 2
    • Groups 0

    Atrix

    @Atrix

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Atrix Unfollow Follow

    Latest posts made by Atrix

    • Adding woocommerce SKU and taxonomy

      Will this work?

      add_filter('wpfts_index_post', function($index, $post) {
      	global $wpdb;
      
      	// Basic tokens
      	/*
      	 * This piece of code was commented out intentionally to display things
      	 * which was already done before in the caller code
      	$index['post_title'] = $post->post_title;
      	$index['post_content'] = strip_tags($post->post_content);
      	*/
      	if ($post->post_type == 'product') {
      
      		$prefix = $wpdb->prefix;
                      //easy way to get all taxonomy even from other modules
      		$sql = " 
      			SELECT * FROM {$prefix}term_relationships AS tr
      			LEFT JOIN {$prefix}term_taxonomy AS tt ON ( tt.term_taxonomy_id = tr.term_taxonomy_id )
      			LEFT JOIN {$prefix}terms AS t ON ( t.term_id = tt.term_id )
      			WHERE tr.object_id = {$post->ID}
      		";
      		$taxonomy = $wpdb->get_results($sql,ARRAY_A);
      		foreach($taxonomy as $t){
      			$p[$t['taxonomy']] =$t['name'];
      		}
      		$data = array();
      		$data[] = get_post_meta($post->ID, '_sku', true);
                      //for parts with diff SKU with diff vendor stored in custom fields
      		$data[] = get_post_meta($post->ID, 'MPN Number', true);
      		$data[] = get_post_meta($post->ID, 'MPN2 Number', true);
      		$index['sku'] = implode(' ', $data);
      		$index['product_taxonomy'] = implode(' ', $taxonomy);
      	}
      	return $index;
      }, 3, 2);
      
      posted in General Discussion
      A
      Atrix