NO BUG: Filters and Infinite Scroll broken PHP Query

Browser: Google Chrome 138.0.7204.50
OS: Windows 11
Video: Jam

It seems that when using a PHP query, the Infinite Scroll and Filters get broken.
With a simple query, it seems to work, so I assume it’s because if the more complex query.
The PHP query:

$parent_product_category_id = '{url_parameter:kategorie-produktu}';

if ( ! is_product_tag() || ! ( $current_tag_object = get_queried_object() ) ) {
    return [ 'post__in' => [0] ]; 
}

$tax_query = [
    [
        'taxonomy' => 'product_tag',
        'field'    => 'term_id',
        'terms'    => $current_tag_object->term_id,
    ],
];

if ( ! empty( $parent_product_category_id ) ) {

    $child_category_ids = get_term_children( (int) $parent_product_category_id, 'product_cat' );

    $category_ids_to_query = array_merge( [ (int) $parent_product_category_id ], $child_category_ids );

    $tax_query['relation'] = 'AND';

    $tax_query[] = [
        'taxonomy' => 'product_cat',
        'field'    => 'term_id',
        'terms'    => $category_ids_to_query,
        'operator' => 'IN',
    ];
}

return [
    'post_type'      => 'product',
    'post_status'    => 'publish',
    'posts_per_page' => 6,
    'tax_query'      => $tax_query,
];

Can you help with that?

All AJAX-related actions in Bricks utilize REST API endpoints.

Hence, is_product_tag, get_queried_object etc might not be your expected value.

Additionally, {url_parameter:kategorie-produktu} will be empty because no URL parameter will be retrieved in the Bricks API endpoints. You can inspect the network requests via the browser developer tool.

Regards,
Jenn

Thank you for the explanation.
Is there a way to refactor the query so it is compatible with the AJAX actions?
I know it’s my job to figure it out, but any help is appreciated either way!
Have a great day!
Petr