Sunday, 21 July 2013

Product sort order on browse/category view - ascending to descending

Problem:
When i show virtuemart home page the product will show in ASC order , (the oldest first) how can i change this with the newest first ?
In the configuration i use date_created_on , if i press this option (in selectbox) is correct but i would that was by default

Solution:
change file: /administrator/components/com_virtuemart/models/product.php
Find the following code:
Code: [Select]
/* invert order value set*/
if ($order =='ASC') {
$orderlink ='&order=DESC';
$orderTxt = JText::_('COM_VIRTUEMART_SEARCH_ORDER_DESC');
} else {
$orderTxt = JText::_('COM_VIRTUEMART_SEARCH_ORDER_ASC');
$orderlink ='';
}

and just switch the order. Be AWARE that this will change all your default sort by to descend.

ALSO, Do you have SEF on or off?

if SEF on, then go to /components/com_virtuemart/router.php.
Inside the file, move the following:
Code: [Select]
if ( isset($query['order']) ) {
if ($query['order'] =='DESC') $segments[] = $helper->lang('orderDesc') ;
unset($query['order']);
}
to after 
Code: [Select]
if ( isset($query['orderby']) ) {
$segments[] = $helper->lang('by').','.$helper->lang( $query['orderby']) ;
unset($query['orderby']);
}

No comments:

Post a Comment