I have a custom view that is currently displaying two post types correctly.
However, I need to be able to filter out the "child" posts if a relationship exists between any of the post types.
I have setup a one-to-many relationship between Pages (one) to Products (many).
This means that I may have multiple products connected to 1 page.
I would like to create a view where if any page has a connected product, then that product should NOT be displayed in the results. If no relationship is present for that product, then it should appear in the results.
If you have created this relationship with Types 3 (rather than Types 2) then the relationship is stored in a custom database table and is no longer stored as post meta (with the _wpcf_belongs_parent-slud_id key), in which case your meta query outlined above would be ineffective.
The results show woocommerce products and a new custom post type called "auction-pages" (created by types).
It is a One to Many relationship between Auction Pages (one) to Products (many).
For example:
Product 1 -> Auction Page A
Product 2 -> Auction Page A
In this example I would like the query to only display Auction Page A, but not show Product 1 or Product 2 in the results since they are connected. If however a product is NOT connected to any Auction Page, then it should appear in the results.
Because the relationships are stored in custom database tables you cannot simply modify the arguments of an existing View (which is based on WP_Query) to additionally exclude/include related posts.
You must use the Toolset relationships API to establish which posts you want, in this case, to exclude.
(You want to exclude all product posts which have a related auction page.)
You can either expand the code you have above which runs with wpv_filter_query *before* the query occurs.
In that case you have the query results available and you loop over all of the results and, for products, you again use toolset_get_related_post to try and get the parent auction-page. If there is one then you would remove the post from the results (and would also need to decrement found_posts and post_count each time).