Call product search from custom hook

What I understood is that no AJAX is needed. If somebody don’t understand all the fancy example around, you just need to use the pre_get_posts hook. In my case what I did is:

function custom_product_search($query) {
    $query->query_vars['post_parent'] = htmlentities($_GET['model']) ?? htmlentities($_GET['make']);
    return $query;
}
add_action("pre_get_posts", 'custom_product_search');

I don’t know if this is the correct solution but it is working one.