I use Joomla 2.5.6 an VM 2.0.8e
this is from
administrator/components/com_virtuemart/models/product.php
/* reorder product in one category
* TODO this not work perfect ! (Note by Patrick Kohl)
*/
function saveorder ($cid = array(), $order, $filter = NULL) {
JRequest::checkToken () or jexit ('Invalid Token');
$virtuemart_category_id = JRequest::getInt ('virtuemart_category_id', 0);
$q = 'SELECT `id`,`ordering` FROM `#__virtuemart_product_categories`
WHERE virtuemart_category_id=' . (int)$virtuemart_category_id . '
ORDER BY `ordering` ASC';
$this->_db->setQuery ($q);
$pkey_orders = $this->_db->loadObjectList ();
$tableOrdering = array();
foreach ($pkey_orders as $order) {
$tableOrdering[$order->id] = $order->ordering;
}
// set and save new ordering
foreach ($order as $key => $ord) {
$tableOrdering[$key] = $ord;
}
asort ($tableOrdering);
$i = 1;
$ordered = 0;
foreach ($tableOrdering as $key => $order) {
// if ($order != $i) {
$this->_db->setQuery ('UPDATE `#__virtuemart_product_categories`
SET `ordering` = ' . $i . '
WHERE `id` = ' . (int)$key . ' ');
if (!$this->_db->query ()) {
vmError ($this->_db->getErrorMsg ());
return FALSE;
}
$ordered++;
// }
$i++;
}
if ($ordered) {
$msg = JText::sprintf ('COM_VIRTUEMART_ITEMS_MOVED', $ordered);
}
else {
$msg = JText::_ ('COM_VIRTUEMART_ITEMS_NOT_MOVED');
}
JFactory::getApplication ()->redirect ('index.php?option=com_virtuemart&view=product&virtuemart_category_id=' . $virtuemart_category_id, $msg);
}
/**
* Moves the order of a record
*
* @param integer The increment to reorder by
*/
function move ($direction, $filter = NULL) {
JRequest::checkToken () or jexit ('Invalid Token');
// Check for request forgeries
$table = $this->getTable ('product_categories');
$table->move ($direction);
JFactory::getApplication ()->redirect ('index.php?option=com_virtuemart&view=product&virtuemart_category_id=' . JRequest::getInt ('virtuemart_category_id', 0));
}