Yes.. We already tried this as described in the definition in nodeorder module. But it seems that the DrupalCommerce view does not offer the weight_in_tid in the sort options. Maybe a relationship is wrong, or the view is already altered by DrupalCommerce view... Something was wrong.
We ended up sorting the view by altering it programatically like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function hook_views_post_execute(&$view) {
if ('collection_products' == $view->name) {
$orders = array();
foreach($view->result as $row) {
$nid = $row->entity;
$tid = $view->args[0];
$weight = db_query("SELECT weight FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid", array(':nid' => $nid, ':tid' => $tid))->fetchField();
$orders[] = $weight;
}
array_multisort($orders, SORT_ASC, $view->result);
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The hard way. ;)
Comments
Hi Mastap,
I am attempting to do this myself, please could you let me know how I implement this suggestion of yours.
Many thanks in advance
Alex