• Hello guys,
    Excellent plugin, everything works as expected, no complains.
    However, we got about 8000 brands and the dropdown at admin product list page is very very hard to search into even with alphabetical order.
    How can i include the brand taxonomy at the admin product search results? For eg, i search for pepsi and the products shown have pepsi as a Berocket brand.

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Cityproject

    (@nikpar)

    I tried extending the admin search with the following function:

    add_filter( 'posts_search', 'woocommerce_search_product_tag_extended', 999, 2 );
    function woocommerce_search_product_tag_extended( $search, $query ) {
        global $wpdb, $wp;
    
        $qvars = $wp->query_vars;
    
        if ( is_admin() || empty($search) ||  ! ( isset($qvars['s'])
        && isset($qvars['post_type']) && ! empty($qvars['s'])
        && $qvars['post_type'] === 'product' ) ) {
            return $search;
        }
        
        // Here set your custom taxonomy
        $taxonomy = 'berocket_brand'; // WooCommerce product tag
    
        // Get the product Ids
        $ids = get_posts( array(
            'posts_per_page'  => -1,
            'post_type'       => 'product',
            'post_status'     => 'publish',
            'fields'          => 'ids',
            'tax_query'       => array( array(
                'taxonomy' => $taxonomy,
                'field'    => 'name',
                'terms'    => esc_attr($qvars['s']),
            )),
        ));
    
        if ( count( $ids ) > 0 ) {
            $search = str_replace( 'AND (((', "AND ((({$wpdb->posts}.ID IN (" . implode( ',', $ids ) . ")) OR (", $search);
        }
        return $search;
    }

    but it doesnt work. Any ideas anyone?

    Plugin Author RazyRx

    (@razyrx)

    Hello,

    Plugin do not have option like this.
    It can be done only with help of own custom code and it must use combination of PHP and JavaScript codes to search brands on product edit page.

    Regards,
    Oleg

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to include brands in admin search?’ is closed to new replies.