London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Order by Created in PurchaseOrder.Search

Vote:
 

Here we go again. Something apparently easy to do, does not behave as expected in Commerce...

So Created (creation timestamp) is actually a metafields (in the db) even tho is a property of the OrderGroup (so all tables that extend OrderGroup ofcourse has it) ... and everyone go huh?!?!?!

I can specify a where clause on the metafield using the property SqlMetaWhereClause on the OrderSearchParameters. So where so i specify an OrderByClaus for metafields? (it does not exist and the OrderByClaus does not recognize the meta fields columns).

So the question is ... tada ... how do i order my search on metafield values?

#62487
Oct 25, 2012 18:02
Vote:
 

There is currently no "out of the box" way to order by MetaField values when searching for orders in Commerce. This is because the stored procedure being used, ecf_OrderSearch, does not return all columns of an OrderGroup meta class table (e.g. OrderGroup_PurchaseOrder) in one of the subqueries being built.

One quick hack you could do is to change the ecf_OrderSearch stored procedure to do exactly what I just said does not happen, by changing

SELECT DISTINCT U.[KEY], U.RANK

to

SELECT DISTINCT U.*

and then using something like

OrderByClause = "META.Created ASC"

but "SELECT *" is not the ideal solution in an ideal world.. This would probably be a feature request for a future release.

#62497
Edited, Oct 26, 2012 2:28
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.