<p>Probably the most Craft-y way would be to use categories for classification and set your categories to have URLs.</p>

<p>Alternatively, you could do this with a route that points <code>shop/*</code> (ie. <code>shop/{some token}</code> - at a template, say <code>shop/product_type</code> and in that template use the second segment of the url in retrieving products of the appropriate type (or, of course, create 3 routes and 3 templates if they way you're handling those index pages differs a lot).</p>

<p>In general how Craft deals with routes/urls is documented here:
<a href="https://craftcms.com/docs/routing" rel="nofollow noreferrer">https://craftcms.com/docs/routing</a>
And some more info on routes is here:
<a href="https://straightupcraft.com/events/routes-and-patterns" rel="nofollow noreferrer">https://straightupcraft.com/events/routes-and-patterns</a></p>

<p>Then to create your menu/list or whatever, something like:</p>

<pre><code>{% for productType in craft.commerce.productTypes %}
  &lt;a href="/shop/{{ productType.handle }}"{{ productType.name }}&lt;/a&gt;&lt;br&gt;
{% endfor %}
</code></pre>

<p>(on phone so excuse any syntax errors)</p>

CC BY-SA 3.0
2017-05-04T02:43:13.727Z
I'm seriously impressed you typed all of that on a phone.
Brad Bell
CC BY-SA 3.0
2017-05-04T02:46:35.830Z
I've learned swipe (swype?) typing lately which is great for a lot of things, but all the formatting stuff is a major PITA still.  But I like to do a little helping over brekky and I can get away with it as long as I don't go sit at my pc ;)
Jeremy Daalder
CC BY-SA 3.0
2017-05-08T11:38:55.450Z
Thank you Jeremy, this is working great! I have decided to add categories - the only issue at this point is how I filter the products. For example shop/gift -  I want only the gift products there. 
do you have any idea?
Özlem
CC BY-SA 3.0
2017-05-08T23:35:01.977Z
Really that's a separate question almost, but basically something like this - if the second url segment is the product type handle:

`{% set products = craft.commerce.products.type(craft.request.getSegment(2)).find()`

or if it is a categories slug in there for example:

`{% set category = craft.categories.slug(craft.request.getSegment(2)) %} {% set products = craft.commerce.products.relatedTo(category) %}`
Jeremy Daalder
CC BY-SA 3.0
2017-05-08T23:36:25.193Z
See documentation here: https://craftcommerce.com/docs/craft-commerce-products
Jeremy Daalder
CC BY-SA 3.0
2017-10-04T17:29:51.157Z
Aren't productType.handle's camel case? This wouldn't be appropriate for a URL right? is there no ability to get a slug from the product type?
ToddPadwick
CC BY-SA 3.0
2017-10-08T23:14:17.543Z
Well by default they are, but you can set them manually of course.  But the types are to separate data concerns, you should probably be using categories if you want taxonomies and url stuff.  But that's really a question on it's own, too long to discuss here
Jeremy Daalder
CC BY-SA 3.0
2017-05-03T23:44:25.217Z
2017-05-03T23:44:25.217Z
Jeremy Daalder
<p>I'm working for the first time with Craft Commerce and trying to create product types. So far so good, now I have three product types: "Inspiration", "Gift" and "New". I need the URL of these three product types and don't know how to create it... actually the URL is <code>shop/products</code> with all products. </p>

<p>I need <code>shop/inspiration</code> with the inspiration products, <code>shop/gift</code> with the gift products and shop/new with the new products.</p>

<p>With <code>{{ productType.name }}</code> I can show all my product types, but how can I show the URL of product types?</p>

<pre><code>{% for productType in craft.commerce.productTypes %}
  {{ productType.name }}&lt;br&gt;
    {% for product in craft.commerce.products.type(productType.handle).find() %}
      {{ product.url }}&lt;br&gt;
    {% endfor %}
{% endfor %}
</code></pre>

<p>Or do I need to create these product types as categories?</p>

<p>Hope you guys can help me!</p>

<plugin-craftcommerce><products>
Craft Commerce - Product Types URL
# Craft Commerce - Product Types URL

(Asked by: username_0 on 2017-05-03)

I'm working for the first time with Craft Commerce and trying to create product types. So far so good, now I have three product types: "Inspiration", "Gift" and "New". I need the URL of these three product types and don't know how to create it... actually the URL is shop/products with all products. 
I need shop/inspiration with the inspiration products, shop/gift with the gift products and shop/new with the new products.
With {{ productType.name }} I can show all my product types, but how can I show the URL of product types?
{% for productType in craft.commerce.productTypes %}
  {{ productType.name }}
    {% for product in craft.commerce.products.type(productType.handle).find() %}
      {{ product.url }}
    {% endfor %}
{% endfor %}

Or do I need to create these product types as categories?
Hope you guys can help me!

**Tags:** plugin-craftcommerce, products


---

## 1 answers

### Answer by username_1 on 2017-05-03. Score: 1 | Accepted answer

Probably the most Craft-y way would be to use categories for classification and set your categories to have URLs.
Alternatively, you could do this with a route that points shop/* (ie. shop/{some token} - at a template, say shop/product_type and in that template use the second segment of the url in retrieving products of the appropriate type (or, of course, create 3 routes and 3 templates if they way you're handling those index pages differs a lot).
In general how Craft deals with routes/urls is documented here:
https://craftcms.com/docs/routing
And some more info on routes is here:
https://straightupcraft.com/events/routes-and-patterns
Then to create your menu/list or whatever, something like:
{% for productType in craft.commerce.productTypes %}
  
{% endfor %}

(on phone so excuse any syntax errors)

> **Comments:**
> **username_2**: I'm seriously impressed you typed all of that on a phone.  
> **username_1**: I've learned swipe (swype?) typing lately which is great for a lot of things, but all the formatting stuff is a major PITA still.  But I like to do a little helping over brekky and I can get away with it as long as I don't go sit at my pc ;)  
> **username_0**: Thank you Jeremy, this is working great! I have decided to add categories - the only issue at this point is how I filter the products. For example shop/gift -  I want only the gift products there.  do you have any idea?  
> **username_1**: Really that's a separate question almost, but basically something like this - if the second url segment is the product type handle:  `{% set products = craft.commerce.products.type(craft.request.getSegment(2)).find()`  or if it is a categories slug in there for example:  `{% set category = craft.categories.slug(craft.request.getSegment(2)) %} {% set products = craft.commerce.products.relatedTo(category) %}`  
> **username_1**: See documentation here: https://craftcommerce.com/docs/craft-commerce-products  
> **username_3**: Aren't productType.handle's camel case? This wouldn't be appropriate for a URL right? is there no ability to get a slug from the product type?  
> **username_1**: Well by default they are, but you can set them manually of course.  But the types are to separate data concerns, you should probably be using categories if you want taxonomies and url stuff.  But that's really a question on it's own, too long to discuss here  

---

