News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Maintain Category view sort order on return from Product Details view

Started by optmax, August 17, 2013, 17:56:34 PM

Previous topic - Next topic

optmax

VM 2.0.22a
Joomla! 2.5.14

I would like to maintain the shopper's choice of sort and sort direction in the Category view when they return from a ProductDetails view (as they click on the 'back-to-category' link).

Nb the changes I suggest in
http://forum.virtuemart.net/index.php?topic=117523.msg399701#msg399701
must also be incorporated. (These correct the misbehavior of the Category view sort being ignored when the default sort is re-selected.)

In administrator/components/com_virtuemart/models/product.php
add two functions
public function getLastProductOrderDirection($default = 'ASC'){
$session = JFactory::getSession();
return $session->get('vmlastproductorderdirection', $default, 'vm');
}

public function setLastProductOrderDirection($order){
$session = JFactory::getSession();
return $session->set('vmlastproductorderdirection', (string) $order, 'vm');
}

   
and at around line 2056
After
$order = JRequest::getWord ('order', 'ASC');
Add
$this->setLastProductOrderDirection($order);

In components/com_virtuemart/views/productdetails/tmpl/default.php or its override
at around line 93
change
<?php // Back To Category Button
if ($this->product->virtuemart_category_id) {
$catURL =  JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->product->virtuemart_category_idFALSE);
$categoryName $this->product->category_name ;
} else {
$catURL =  JRoute::_('index.php?option=com_virtuemart');
$categoryName jText::_('COM_VIRTUEMART_SHOP_HOME') ;
}
?>

to
<?php // Back To Category Button
if ($this->product->virtuemart_category_id) {
$filter_orderby VirtueMartModelProduct::getLastProductOrdering();
if($filter_orderby == "0"){
$filter_orderby =VmConfig::get ('browse_orderby_field');
$filter_orderdir_text ''
}
else {
$filter_orderdir VirtueMartModelProduct::getLastProductOrderDirection();
if(($filter_orderdir == "0") || ($filter_orderdir == "ASC")){
$filter_orderdir_text '';
}
else {
$filter_orderdir_text .= '&order=' $filter_orderdir;
}
}
$filter_orderby_text '&orderby='.$filter_orderby;
$catURL =  JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->product->virtuemart_category_id $filter_orderby_text $filter_orderdir_text );
$categoryName $this->product->category_name ;
} else {
$catURL =  JRoute::_('index.php?option=com_virtuemart');
$categoryName jText::_('COM_VIRTUEMART_SHOP_HOME') ;
}
?>

kok

Many thanks to all the great work!
Until the next update ... :-)
Joomla! 2.5.27
VirtueMart 2.6.10

Milbo

Would be good to have a patch for both issues. Please read http://dev.virtuemart.net/projects/virtuemart/wiki/Setting_up_a_Development_Environment and create a patch for us, for the latest version.

Be aware that the provided link of the svn is for vm2.1.x
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/