我想覆盖WC_Product_Data_Store_CPT :: search_products() 该函数位于从第1193行开始的class-wc-order-data-store-cpt.php中。
我可以删除/覆盖我想要的行但是如果更新woocommerce,我的更改将会消失。 有没有办法在不触及WC核心的情况下在functions.php中执行此操作?
我只是想从查询中删除posts.post_content以加快搜索速度。
$product_ids = $wpdb->get_col(
$wpdb->prepare( "
SELECT DISTINCT posts.ID FROM {$wpdb->posts} posts
LEFT JOIN {$wpdb->postmeta} postmeta ON posts.ID = postmeta.post_id
$type_join
WHERE (
posts.post_title LIKE %s
OR posts.post_content LIKE %s
OR (
postmeta.meta_key = '_sku' AND postmeta.meta_value LIKE %s
)
)
AND posts.post_type IN ('" . implode( "','", $post_types ) . "')
AND posts.post_status IN ('" . implode( "','", $post_statuses ) . "')
$type_where
ORDER BY posts.post_parent ASC, posts.post_title ASC
",
$like_term,
$like_term,
$like_term
)
);