As per
https://github.com/craftcms/commerce/issues/380
https://github.com/craftcms/commerce/issues/454
The variants of disabled products appear within queries
For instance {% set results = craft.variants %} will return product variants from products that have been disabled.
Disabling the variants themselves prevents them appearing. However, it's no possible to disable the default variant so that is still showing (even when the product is disabled).
Thanks for submitting the issue.
We plan to leave this as it is for now, you can achieve what you need with:
{% set results = craft.variants.hasProduct({'status':'enabled'}).all() %}
On a technical note, If you query for a matrix block, it doesn't factor in if the owner (entry) is disabled.
Thanks for the tip to get around it.
It does, however, feel broken. It does not seem logical that the query would return variants of disabled products when querying for products wouldn't return those that were disabled unless specifically added as a clause.
Most helpful comment
Thanks for the tip to get around it.
It does, however, feel broken. It does not seem logical that the query would return variants of disabled products when querying for products wouldn't return those that were disabled unless specifically added as a clause.