Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-30T17:47:25.667Z
Comments.Text: This is going to be very difficult to debug without seeing any of the relevant plugin code or the error message.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-07T12:58:31.233Z
Comments.Text: @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.
Comments.UserDisplayName: Gustavs
Tags: <plugin-development><elementtype>
Title: Ordering elementtype by custom field throws an error
ThreadText: # 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**: @username_1 - 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
  
  