I am using Craft Commerce for the first time and am trying to dynamically generate a dropdown menu that contains links to each product type. I thought the best way to accomplish this would be by using a parameter in the URL i.e.


I would be able to get the handle of the selected product type by using:


I have two roadblocks that are preventing me from implementing this:

  1. How do I get an array of all the product types so I can build the dropdown?

  2. How do I get the name of a product type once I have the handle so I can display a Header at the top of the page based on the selected product type?

Also, is there a better way of implementing similar functionality that I am simply overlooking?


2 Answers 2


You can get all product types within your templates with:

{% for productType in craft.commerce.productTypes %}
  {{ productType.name }}<br>
{% endfor %}

There is no way to get a specific product type within templates at the moment, but I have added to the list. In the meantime you would need to look over all and find the one you want as above.

  • 1
    Awesome, this is working great! Thank you! The only issue I have at this point is how to get the handle from productType, productType.handle doesn't seem to be working and the product type page in the docs isn't completed yet. Mar 21, 2016 at 18:45

To expand on Luke's answer, you might try something like:

<form action="">
  <select name="availableProductTypes">
     {% for theType in craft.commerce.productTypes %}
        <option value="{{theType}}">{{theType.name}}</option>
     {% endfor %}
  <input type="submit" value="Show">

Then you can show what was selected in the dropdown:

{% if craft.request.getParam('availableProductTypes') %}

 {% set theType = craft.request.getParam('availableProductTypes') %}

  {% for product in craft.commerce.products.type(theType).find() %}
  {% else %}
   <li>No products found.</li>
 {% endfor %}

{% endif %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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