<p>Product <em>types</em> are really all about data concerns - so if the data you're storing for your canines/equines (hereafter known as dogs and horses to save some typing ;) ) - is the same, then you're right you don't need more than one product type.  So let's say you make one type of product <code>Animal</code>.  </p>

<p>The most obvious tool for grouping that Craft provides is categories.  You might make a category <em>group</em> of <code>Animal Categories</code>, and then two categories in that <code>Dogs</code> and <code>Horses</code>.  You then add a categories <em>field</em> to your product type and select that category <em>group</em> as the source.</p>

<p>Then, when entering each product, you just choose the appropriate category at that time (i.e. you don't so much assign product to a category from the category itself, rather the product is related to the category using the field on the product entry).</p>

<p>In terms of then listing those on a listing (rather than individual) page, in the category settings, set your categories to resolve to e.g. <code>animals/{slug}</code> (i.e. an actual url might be <code>animals/dogs</code> and define a template for Craft to use.</p>

<p>When someone hits that url, your chosen template will be loaded, and this template will have an auto-populated variable of <code>category</code> you can then use that to filter your products display</p>

<pre><code>{% set products = craft.commerce.product.relatedTo(category) %}
{% for product in products %}
    etc.
</code></pre>

<p>That's the basics of doing a listing  </p>

<p>To sort orders, you can do it in any normal Craft way, such as by the title in alphabetic order:</p>

<pre><code>{% set products = craft.commerce.product.relatedTo(category).order('title asc') %}
</code></pre>

<p>If you want an explicit order, you can do it at the template level by <code>id</code>s and used <code>fixedOrder('true</code>) and so on.  There is currently no GUI method of sorting products in Commerce.</p>

<p>(It is fair to say though that it would be nice to have a native ability to create a default sort order for products in the back end, by e.g. drag and drop, which does not exist currently.  You can achieve this by using a Commerce Products field (which is really a relations field, just to products) - and simply manually sort all your product in that, and use that field to build your listings, but this is kind of frustrating to be honest - as where you then store that field?  We use a global set for this currently but it's not ideal). </p>

CC BY-SA 3.0
2016-07-22T11:03:31.553Z
Thanks for the answer Jeremy. I am glad you said it isn't possible to order products currently via the GUI, as I thought I was just overlooking something. Hope this would be a feature that might arrive in the future.  

As for the last part about manually sort all your products via  Commerce Products field and global set. Could you elaborate a little on this as I don;t fully understand I am afraid.
Terry Upton
CC BY-SA 3.0
2016-07-22T11:03:36.303Z
As the shop only has a few products and these are based in equine and canine categories explicitly, I wondered if categories was necessary and if having two product types (allbeit they are the same) would work? But you think it would still be better to use Categories for this?
Terry Upton
CC BY-SA 3.0
2016-07-22T11:11:03.213Z
I'm on my phone but I suppose you could use types, although I can't see much benefit, but sure - either way should work. I guess I like to go with the natural way in case needs change later.   OK create a global set called whatever.  Then create a field of type commerce products.  Add this to your global. You can then use this to order your products (try it!). Then if you retrieve these in your template you'll get them in the order they are in the firkd, by default. I can add more tomorrow if need be, but Friday night beckons....
Jeremy Daalder
CC BY-SA 3.0
2016-07-22T11:36:31.327Z
Might be worth adding this as a feature request?
Clive Portman
CC BY-SA 3.0
2016-07-23T04:15:02.063Z
It's already there actually - http://feedback.craftcms.com/forums/295386-commerce/suggestions/12445254-manual-sorting-of-products - vote if you have an interest!
Jeremy Daalder
CC BY-SA 3.0
2016-07-23T04:16:35.737Z
@TerryUpton I should add that a global is not really the right place for storing this field - unless it really is something you want globally available.  You could instead set up a section to hold your sort orders if you have a few of them, to stop this data poluting the global space (global data requires a query for every page load so it's not ideal for performance really either)

With any luck manual sorting will come along soon, anyway.
Jeremy Daalder
CC BY-SA 3.0
2016-07-23T12:42:57.570Z
Thanks for the input Jeremy. As there are only a few products on this particular store I will add them in the order I want them to appear and sort by postdate (assuming this is possible). I see with larger stores/commerce platforms you are likely to sort by price in most instances. With this particular store, the products are quite niche, and with there only being a handful, the need to appear in a set order.
Terry Upton
CC BY-SA 3.0
2016-07-22T00:11:01.910Z
2016-07-22T00:11:01.910Z
Jeremy Daalder
<p>What is the best method to organise products, and subsequently the order of these products within a group?</p>

<p>Currently I have setup a product type of Canine. I can access each of these products via a URL of /canine/productslug/ but I am unable to change the order of these products when viewed at /commerce/products/.</p>

<p>The shop will consist of two sections Canine and Equine. I don't think I need to have two product types as they contain the same structure/layout/format. So I can perhaps change the product type to general.</p>

<p>However, being new to Craft, I am unsure how I should be structuring these products? Presumably I need to create either categories or structures and then assign products to these?</p>

<p>I have done some searching but can't find anything to direct me over how I should be setting up the shop for product listings.</p>

<p>Can anyone offer some direction, advise or pointers for this?</p>

<categories><structure><plugin-craftcommerce><setup>
Ordering of products?
# Ordering of products?

(Asked by: username_0 on 2016-07-21)

What is the best method to organise products, and subsequently the order of these products within a group?

Currently I have setup a product type of Canine. I can access each of these products via a URL of /canine/productslug/ but I am unable to change the order of these products when viewed at /commerce/products/.

The shop will consist of two sections Canine and Equine. I don't think I need to have two product types as they contain the same structure/layout/format. So I can perhaps change the product type to general.

However, being new to Craft, I am unsure how I should be structuring these products? Presumably I need to create either categories or structures and then assign products to these?

I have done some searching but can't find anything to direct me over how I should be setting up the shop for product listings.

Can anyone offer some direction, advise or pointers for this?

**Tags:** categories, structure, plugin-craftcommerce, setup

---

## 1 answers

### Answer by username_1 on 2016-07-22. Score: 7 | Accepted answer

Product types are really all about data concerns - so if the data you're storing for your canines/equines (hereafter known as dogs and horses to save some typing ;) ) - is the same, then you're right you don't need more than one product type.  So let's say you make one type of product Animal.  
The most obvious tool for grouping that Craft provides is categories.  You might make a category group of Animal Categories, and then two categories in that Dogs and Horses.  You then add a categories field to your product type and select that category group as the source.
Then, when entering each product, you just choose the appropriate category at that time (i.e. you don't so much assign product to a category from the category itself, rather the product is related to the category using the field on the product entry).
In terms of then listing those on a listing (rather than individual) page, in the category settings, set your categories to resolve to e.g. animals/{slug} (i.e. an actual url might be animals/dogs and define a template for Craft to use.
When someone hits that url, your chosen template will be loaded, and this template will have an auto-populated variable of category you can then use that to filter your products display
{% set products = craft.commerce.product.relatedTo(category) %}
{% for product in products %}
    etc.

That's the basics of doing a listing  
To sort orders, you can do it in any normal Craft way, such as by the title in alphabetic order:
{% set products = craft.commerce.product.relatedTo(category).order('title asc') %}

If you want an explicit order, you can do it at the template level by ids and used fixedOrder('true) and so on.  There is currently no GUI method of sorting products in Commerce.
(It is fair to say though that it would be nice to have a native ability to create a default sort order for products in the back end, by e.g. drag and drop, which does not exist currently.  You can achieve this by using a Commerce Products field (which is really a relations field, just to products) - and simply manually sort all your product in that, and use that field to build your listings, but this is kind of frustrating to be honest - as where you then store that field?  We use a global set for this currently but it's not ideal).

> **Comments:**
> **username_0**: Thanks for the answer Jeremy. I am glad you said it isn't possible to order products currently via the GUI, as I thought I was just overlooking something. Hope this would be a feature that might arrive in the future.    As for the last part about manually sort all your products via  Commerce Products field and global set. Could you elaborate a little on this as I don;t fully understand I am afraid.  
> **username_0**: As the shop only has a few products and these are based in equine and canine categories explicitly, I wondered if categories was necessary and if having two product types (allbeit they are the same) would work? But you think it would still be better to use Categories for this?  
> **username_1**: I'm on my phone but I suppose you could use types, although I can't see much benefit, but sure - either way should work. I guess I like to go with the natural way in case needs change later.   OK create a global set called whatever.  Then create a field of type commerce products.  Add this to your global. You can then use this to order your products (try it!). Then if you retrieve these in your template you'll get them in the order they are in the firkd, by default. I can add more tomorrow if need be, but Friday night beckons....  
> **username_2**: Might be worth adding this as a feature request?  
> **username_1**: It's already there actually - http://feedback.craftcms.com/forums/295386-commerce/suggestions/12445254-manual-sorting-of-products - vote if you have an interest!  
> **username_1**: @TerryUpton I should add that a global is not really the right place for storing this field - unless it really is something you want globally available.  You could instead set up a section to hold your sort orders if you have a few of them, to stop this data poluting the global space (global data requires a query for every page load so it's not ideal for performance really either)  With any luck manual sorting will come along soon, anyway.  
> **username_0**: Thanks for the input Jeremy. As there are only a few products on this particular store I will add them in the order I want them to appear and sort by postdate (assuming this is possible). I see with larger stores/commerce platforms you are likely to sort by price in most instances. With this particular store, the products are quite niche, and with there only being a handful, the need to appear in a set order.  

---

