[SOLVED] Products OrderBy list update problem when appending OrderBy to URL

Started by optmax, July 27, 2013, 18:35:34 PM

Previous topic - Next topic

optmax

Clean install
Joomla 2.5.13
VM 2.0.22a
Beez20 template

Category Product List default set to Product Name
But I want a different default sort order for products in various categories

eg suppose in Garden tools I want to sort by default on Creation Date

So I create an override default.php template in Categories and on line 63 of default.php add

63     if ($category->category_name == 'Garden Tools') { $caturl = $caturl . '&orderby=created_on&order=DESC'; }

(So if it is Garden Tools an ORDER BY clause will be appended to the URL.)

(Another problem is that the link created by this does not work with the Standard System SEF but does work with the 3rd Party MijjoSEF.  It also works fine with no SEF.)

However appending this Order By clause to the URL causes an anomaly when the OrderBy list is updated:
the appended order by field is added to the OrderBy list even though it is the active OrderBy

See attached screenshot (nb Product Creation date is active, Creation date appears in list - these are the same 'created_on' field with different text settings in the VM language constants associated with the OrderBy list).

This would appear to be (another?  see my other recent posts!) problem in administrator/components/models/product.php

If I change:
2121 foreach ($fields as $field) {
2122      if ($field != $orderby) {
2123


and insert a line to test if the active OrderBy is about to be appended

2121 foreach ($fields as $field) {
2122              if (stripos($field,$orderby)>0) {continue;} // eg  if $field='`p`.created_on' and $ordebry='created_on' do nothing, just  process to next $field
2123      if ($field != $orderby) {


I am not certain this is the right place to be testing for this, the problem could be deeper. Possible where the table prefix `p`. is prepended? (by the checkFilterOrder function?).

This code is within the getOrderByList function and on line 2106 there is a comment 'notice by Max Milbers html tags should never be in a model. This function should be moved to a helper or simular,...'.
So maybe this function due a rewrite?

As I alluded above this is the second problem I have come across in products.php in as many days (see post 'Product List Sorting in Category view VM2.0.22a').

So far no one has commented on the previous post - I know you guys are all busy people but it would be nice to know if my posts are being investigated or even  if you have not been been able to duplicate the problems the that would be good to know too!

[attachment cleanup by admin]