<p>In my plugin, when I go to the elementtype index page with the search bar and the dropdown for ordering by certain fields, when I choose a field which has been added through the fieldLayout, the response throws an error.</p>

<p>The problem in the query is in the <code>ORDER BY</code> clause. Specifically: <code>ORDER BY 'field:22'</code>.</p>

<p>How would I go about resolving this issue?<br>
Thanks!</p>

CC BY-SA 3.0
2016-08-30T17:47:25.667Z
This is going to be very difficult to debug without seeing any of the relevant plugin code or the error message.
Brad Bell
CC BY-SA 3.0
2016-09-07T12:58:31.233Z
@BradBell - I found out that Craft Commerce doesn't allow sorting by custom fields, so I assumed it's not available "out of the box" and opted to allow sorting only by the element's own fields.
Gustavs
<plugin-development><elementtype>
Ordering elementtype by custom field throws an error
# Ordering elementtype by custom field throws an error

(Asked by: username_0 on 2016-08-30)

In my plugin, when I go to the elementtype index page with the search bar and the dropdown for ordering by certain fields, when I choose a field which has been added through the fieldLayout, the response throws an error.

The problem in the query is in the `ORDER BY` clause. Specifically: `ORDER BY 'field:22'`.

How would I go about resolving this issue?  
Thanks!

**Tags:** plugin-development, elementtype
> **Comments:**
> **username_1**: This is going to be very difficult to debug without seeing any of the relevant plugin code or the error message.  
> **username_0**: @BradBell - I found out that Craft Commerce doesn't allow sorting by custom fields, so I assumed it's not available "out of the box" and opted to allow sorting only by the element's own fields.  

---

## 0 answers

