I have some default sorted fields in a view and I would love to manipulate the order the fields are in similar to your search_api_sorts does it but with more control.

I have the option to ->getSort() from the SearchApiQuery interface and ->sort($sort, $order) but it's always appending and I have no access to the protected set of sorts in the object SearchApiQuery::$sort.

A couple solutions would be to provide a clearSort() method then I could get the pervious ones, clear them and add them back in the order I would like. Or better yet a setSorts($array) that could just full out replace them.

Thoughts?

Comments

Nick_vh’s picture

Category: Feature request » Support request
Issue summary: View changes

getSort gets it using a reference so you can just change it and it will change it upstream?

/**
   * Retrieves the sorts set for this query.
   *
   * @return array
   *   An array specifying the sort order for this query. Array keys are the
   *   field names in order of importance, the values are the respective order
   *   in which to sort the results according to the field.
   *
   * @see sort()
   */
  public function &getSort();
drunken monkey’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.