I am happy to say that I have found a fix for 2.0.18a
Roughly, here's how to reproduce the bug:
1. Assign products to category A and B
2. In products list view, filter by category B
3. Set ordering for products
4. The ordering is saved to category A instead
The problem is, if a product is assigned to several categories, when you set the ordering for that product in one particular category, Virtuemart will always load and save the ordering to the first category it belongs to.
And here's the fix:
In administrator/components/com_virtuemart/models/product.php , function getProductSingle , line 898
replace this :
} else {
$product->virtuemart_category_id = JRequest::getInt ('virtuemart_category_id', 0);
if (!empty($product->categories) and is_array ($product->categories) and !empty($product->categories[0])) {
$product->virtuemart_category_id = $product->categories[0];
} else {
$product->virtuemart_category_id = 0;
}
}
with this:
} else {
$product->virtuemart_category_id = $this->virtuemart_category_id; // shouldn't get from JRequest. This gets from the filtering state in the model object
if ( !empty($product->virtuemart_category_id) ) {
// don't do anything, we already have the right category id from JRequest
} else if (!empty($product->categories) and is_array ($product->categories) and !empty($product->categories[0])) {
$product->virtuemart_category_id = $product->categories[0];
} else {
$product->virtuemart_category_id = 0;
}
var_dump($product->virtuemart_category_id);
}
I have checked against 2.1 in the SVN trunk and this bug still exists there. Is there any chance this can be merged into 2.1, Max?