Is there a way to dynamically get all the related products based on the product type?

I seem to be getting all the products regardless of product type when I use:

{% set products = craft.commerce.products.relatedTo(category).order('postDate desc') %}

(obviously since I don't have any categories).


I'm a little unclear but I think you're looking for:

{% set products = craft.commerce.products.type('productTypeHandle').order('postDate desc') %}

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.