Don’t update modified post date when user add a product review or comment?

WooCommerce seems to update the ‘last modified’ value of a product on every change. If you want to take a look at the source code, go to woocommerce\includes\data-stores\class-wc-product-data-store-cpt.php and check the function update.

This solution seems to work, however it could be improved to make sure it doesn’t mess up with anything else. Basically checks if the request has info of a comment and filters the query that modifies the post date to skip it. I didn’t find any earlier hook than the query filter.

add_filter('query', function($query){
    if(isset($_POST['comment']) && strpos($query, 'post_modified')){
        return '';
    }
    return $query;
});