Hi Pavel,
i fall into an issue, i think i'am not the only user.
I would really like to extend the atum admin product search to custom fields.
I can't believe a thing that is so easy with standard WC admin product page, is impossible with ATUM.
Any hints to implement this by ourself?
This is the code i use with simple WC product search, to search into my CF: barcode
function m_request_query( $query_vars ) {
global $typenow;
global $wpdb;
global $pagenow;
if ( 'product' === $typenow && isset( $_GET['s'] ) && 'edit.php' === $pagenow ) {
$search_term = esc_sql( sanitize_text_field( $_GET['s'] ) );
$meta_key = 'barcode';
$post_types = array( 'product', 'product_variation' );
$search_results = $wpdb->get_results(
$wpdb->prepare(
"SELECT DISTINCT posts.ID as product_id, posts.post_parent as parent_id FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id WHERE postmeta.meta_key = '{$meta_key}' AND postmeta.meta_value LIKE %s AND posts.post_type IN ('" . implode( "','", $post_types ) . "') ORDER BY posts.post_parent ASC, posts.post_title ASC",
'%' . $wpdb->esc_like( $search_term ) . '%'
)
);
$product_ids = wp_parse_id_list( array_merge( wp_list_pluck( $search_results, 'product_id' ), wp_list_pluck( $search_results, 'parent_id' ) ) );
$query_vars['post__in'] = array_merge( $product_ids, $query_vars['post__in'] );
}
return $query_vars;
}
add_filter( 'request', 'm_request_query', 20 );
Best, M