[SOLVED] Product List Sorting in Category view VM2.0.22a

Started by optmax, July 26, 2013, 00:39:05 AM

Previous topic - Next topic

optmax

VM2.0.22a
Joomla 2.5.11

Please see
http://forum.virtuemart.net/index.php?topic=117523.msg399701#msg399701
for my revised solution

I have:
Default product sort order: Product id
Available Sort-by fields:  Product id and Product Name

Initial listing of products within a category defaults to order by Product id - no problem, order may be reversed by clicking on Product id in the activeOrder - no problem.
Order may be changed to by Product Name by clicking in the orderlist - no problem, and the new order reversed - no problem.

BUT...
When sort order is put back to by Product id the products displayed remain sorted by Product Name.

The only way to get the list sorted by Product id again is to clear the browser cache and reload the page so I guess some session variable may be at fault?

As a temporary fudge/fix I have cured this by changing two lines of code in administrator/components/com_virtuemart/models/products.php
At line 144 to 147 old code
if($filter_order == "0"){
$filter_order_raw = $this->getLastProductOrdering($this->_selectedOrdering);
$filter_order = $this->checkFilterOrder ($filter_order_raw);
} else {

New code
if($filter_order == "0"){
$filter_order = '`p`.virtuemart_product_id';
$filter_order = $this->checkFilterOrder ($filter_order);
} else {


I am not offering this a permanent solution as it is specific to my configuration and there may well be unwanted side effects.

However it may have a bearing on the various other problems reported in this forum about Product list sorting.

optmax

Some screenshots to illustrate the problem

Clean install
Joomla 2.5.13
VM  2.0.22a
Beez20 template

Default sort by product id
Available sort field Product id, Product Name, Manufacturer Name and Creation date.

One override category/default.php in which I have appended the virtuemart_product_id to the front of the product_name.
This override applied to Garden Tools category view.

Screenshot 01 - the default sort order by Product id - All OK
Screenshot 02 - sorted on Product Name - All OK
Screenshot 03 - now sorted by Product id again - clearly a problem

Any sort order except Product id works.
Product id sort order can be restored by clearing the browser cache and reloading.
Or...
Screenshot 04 - 'by,product_id' has been appended to the URL, order restored but note the odd sort box entry

See next post for:
Screenshot 05 - 'by,virtuemart_product_id ' has been appended to the URL, order restored and all OK again


[attachment cleanup by admin]

optmax

See previous reply for explanation and screenshots 1 -4

Here is
Screenshot 05 - 'by,virtuemart_product_id ' has been appended to the URL, order restored and all OK again

[attachment cleanup by admin]

optmax

Update...
Problem is not specific to product_id but happens when the SortBy order is reset to the defaults product order field.

When the default ordering is re-selected this choice is ignored and the previous choice remains in force

So as I expected my fudge is specific to Product_Id being the default sort field.

It seems to me that when the default sort order field is re-selected $filter_order in function updateRequests in products.php is set to null or 0 when it should have been set to the default sort order field.

So where is  $filter_order set before updateRequests is called?

optmax

#4
Another update...

I have now resolved the problem in a more generic way (one line of code to alter) and will put my suggestion on the VM2 Coding Central child board