Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Product Variations Searchable but Show only Parent Products as Results › Reply To: Product Variations Searchable but Show only Parent Products as Results
April 19, 2022 at 2:11 pm
#37568
Participant
Thank you Ernest. In the meantime our developers tried with the below and it seems they got the desired result. I will keep a note of your suggestion in case they notice any issues with our approach. Thank you!
add_filter( 'asp_pagepost_results', __CLASS__ . '::remove_variants_products', 1, 1 );
public static function remove_variants_products( $pageposts ) {
foreach ( $pageposts as $post_key => $pagepost ) {
if( $pagepost->post_type == 'product_variation' ) {
unset( $pageposts[$post_key] );
}
}
return $pageposts;
}