Best way to get product types in collections

Solved
doughnut1218411
Shopify Partner
5 0 2

Hello!

 

I'd like to know the best way to get product types data in a specific collection.

What I'm trying to create is something like:

 

 

<ul>
  {% for product_type in collections.types %}
    <li>
      {{ product_type | link_to_type }}
    </li>
  {% endfor %}
</ul>

 

 

but, I couldn't find types object under the collections object.

 

(I think this is how to get product types from ALL products).

 

 

{% for product_type in shop.types %}
{% endfor %}

 

 

 

I could create a link something like this one by one instead (and this should work fine).

But, is there a better way to get types in a specific collections??

 

 

<a href="collections/{collection-name}?filter.p.product_type={product-type1}" >product-type1</a>

 

 

 

thank you.

Accepted Solution (1)

Accepted Solutions
LitExtension
Shopify Partner
3338 657 718

This is an accepted solution.

Hi @doughnut1218411,

You can refer to the all_types property of the collection, refer: https://shopify.dev/api/liquid/objects/collection#collection-all_types

Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!

View solution in original post

Replies 2 (2)
LitExtension
Shopify Partner
3338 657 718

This is an accepted solution.

Hi @doughnut1218411,

You can refer to the all_types property of the collection, refer: https://shopify.dev/api/liquid/objects/collection#collection-all_types

Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
doughnut1218411
Shopify Partner
5 0 2

@LitExtension 

Wow, wicked! That's exactly what I need!

Thank you!