<p>To order the products you'd make the Products section into a structure and display the category you were sorting by in the listing as a table column.</p>

<p>You can then re-order all products to be in category order (using the table column), then re-order each product for each category. </p>

<p>You can then output each product grouped by category with something along the lines of:</p>

<pre><code>{% for cat in categories %}

  {% set products = products.relatedTo( cat ) %}

  {% for product in products %}

    {{ product.title }}

  {% endfor %}

{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-05-19T09:45:50.300Z
2016-05-19T09:45:50.300Z
Luke Pearce
<p>I have a Products Section and a Product Category Structure Section
In Products there is an Entries Field where the Category is selected from the Product Category section.</p>

<p>Is it possible to sort the products per category manually?</p>

<p>I see with the ManytoMany Plugin - <a href="https://github.com/page-8/craft-manytomany" rel="nofollow">https://github.com/page-8/craft-manytomany</a>
You can display the products which appear in each Category and the Custom Ordering of the second Relationship is in the pipeline which would probably work but not available yet.</p>

<p>Is there any other option?</p>

CC BY-SA 3.0
2016-05-19T09:14:27.377Z
So do you want to display the products per category or sort/order the products manually within their categories?
Luke Pearce
CC BY-SA 3.0
2016-05-19T09:16:20.170Z
Both - when I click on the Category on the front end I want to load the products in that category - but I also want to be able to manually sort the order they are displayed.
mmc501
CC BY-SA 3.0
2016-05-19T09:23:59.390Z
To order the products you'd make that section into a structure and display the category you were sorting by in the listing and then re-order all products to be in category order - then re-order each product for each category. I'll test how to then output by category and provide a detailed answer - but it'll be something like `loop through each category - set products to products related to current category - loop through those products`
Luke Pearce
CC BY-SA 3.0
2016-05-19T09:27:37.843Z
Ah - ding - you have it spot on - I was thinking of trying to sort within the categories entry. That will all work. I can Output them no problem.
Thanks for the help - do you want to add that as the answer.
mmc501
<categories><entries-field><sorting>
Sort entries in a category or entries field?
# Sort entries in a category or entries field?

(Asked by: username_0 on 2016-05-19)

I have a Products Section and a Product Category Structure Section
In Products there is an Entries Field where the Category is selected from the Product Category section.

Is it possible to sort the products per category manually?

I see with the ManytoMany Plugin - <https://github.com/page-8/craft-manytomany>
You can display the products which appear in each Category and the Custom Ordering of the second Relationship is in the pipeline which would probably work but not available yet.

Is there any other option?

**Tags:** categories, entries-field, sorting
> **Comments:**
> **username_1**: So do you want to display the products per category or sort/order the products manually within their categories?  
> **username_0**: Both - when I click on the Category on the front end I want to load the products in that category - but I also want to be able to manually sort the order they are displayed.  
> **username_1**: To order the products you'd make that section into a structure and display the category you were sorting by in the listing and then re-order all products to be in category order - then re-order each product for each category. I'll test how to then output by category and provide a detailed answer - but it'll be something like `loop through each category - set products to products related to current category - loop through those products`  
> **username_0**: Ah - ding - you have it spot on - I was thinking of trying to sort within the categories entry. That will all work. I can Output them no problem. Thanks for the help - do you want to add that as the answer.  

---

## 1 answers

### Answer by username_1 on 2016-05-19. Score: 2 | Accepted answer

To order the products you'd make the Products section into a structure and display the category you were sorting by in the listing as a table column.
You can then re-order all products to be in category order (using the table column), then re-order each product for each category. 
You can then output each product grouped by category with something along the lines of:
{% for cat in categories %}

  {% set products = products.relatedTo( cat ) %}

  {% for product in products %}

    {{ product.title }}

  {% endfor %}

{% endfor %}


---

