I need to search for all commerce variants related to a custom element "Account".

The account element is related to a variant through a matrix field with handle
varientaccountmapping, block handle mapping field handle account

{% set allowedVarients = craft.variants().relatedTo({
    targetElement: accountElement,
    field: 'varientaccountmapping.account'
}).all() %}

works, however it returns results whether the matrix block is enabled or disabled - ignoring the status.

How can I get this to return only results where the matrix block it is related to is enabled?


I faced the same problem in Craft v3.4.10 and have been informed that this is a bug, which has now been fixed and will be shipped in v3.4.12.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.