VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Topic started by: SniperSister on February 28, 2012, 15:52:21 pm

Title: Bugfix: Product ordering function
Post by: SniperSister on February 28, 2012, 15:52:21 pm
Hi,

I did some bugfixing on the product ordering function which results in the following patch:

/helpers/shopfunctions.php, line 1169 changed to:
Code: [Select]
'product_unit', 'product_packaging', 'p.virtuemart_product_id','ordering');

/models/products.php, function saveorder changed to:
Code: [Select]
function saveorder($cid , $orders) {
JRequest::checkToken() or jexit( 'Invalid Token' );

$virtuemart_category_id = JRequest::getInt('virtuemart_category_id', 0);

$q = 'SELECT `id`,`ordering` FROM `#__virtuemart_product_categories`
WHERE virtuemart_category_id='.(int)$virtuemart_category_id.'
ORDER BY `ordering` ASC';
$this->_db->setQuery($q);
$pkey_orders = $this->_db->loadObjectList();

$tableOrdering = array();
foreach ($pkey_orders as $order) $tableOrdering[$order->id] = $order->ordering;
// set and save new ordering
foreach  ($orders as $key => $order) $tableOrdering[$key] = $order;
asort($tableOrdering);
$i = 1 ; $ordered = 0 ;
foreach  ($tableOrdering as $key => $order) {
$this->_db->setQuery('UPDATE `#__virtuemart_product_categories`
SET `ordering` = '. $i.'
WHERE `id` = ' . (int)$key . ' ');
if (! $this->_db->query()){
vmError($this->_db->getErrorMsg());
return false;
}
$ordered ++ ;
$i++ ;
}
if ($ordered) $msg = JText::sprintf('COM_VIRTUEMART_ITEMS_MOVED', $ordered);
else $msg = JText::_('COM_VIRTUEMART_ITEMS_NOT_MOVED');
JFactory::getApplication()->redirect('index.php?option=com_virtuemart&view=product&virtuemart_category_id='.$virtuemart_category_id, $msg);

}

Now it seems to be working properly.

Best regards
David
Title: Re: Bugfix: Product ordering function
Post by: skygirl on February 28, 2012, 18:45:54 pm
Thanks very much it's perfect !!!
Title: Re: Bugfix: Product ordering function
Post by: Milbo on February 29, 2012, 15:08:59 pm
Spilka did something simular, will be in the release today.
Title: Re: Bugfix: Product ordering function
Post by: luxuryvps on February 29, 2012, 15:15:02 pm
Will this fix have any effect on my current problem reported here: http://forum.virtuemart.net/index.php?topic=98824.0 ?

Liam
Title: Re: Bugfix: Product ordering function
Post by: beipink on April 10, 2012, 13:12:34 pm
Spilka did something simular, will be in the release today.
Hi Max,
Did you manage to include this fix in the release?
I have updated to 2.0.4 just now and the sorting of products from back-end appear to be still broken!
Title: Re: Bugfix: Product ordering function
Post by: Studio 42 on April 10, 2012, 15:14:14 pm
Hi,
I have read the code, it's exactly the same as your in last SVN files/release(commented line excluded)
Title: Re: Bugfix: Product ordering function
Post by: beipink on April 11, 2012, 14:45:37 pm
Hi,
I have read the code, it's exactly the same as your in last SVN files/release(commented line excluded)
The code might be included and it seems to work in the back-end however the changes are NOT reflected in the frontend.
am I doing something wrong??
Title: Re: Bugfix: Product ordering function
Post by: Studio 42 on April 11, 2012, 18:51:17 pm
If you use sef it"s a mistake in the file and the dev revision is updated.
Without SEF this must work.
Title: Re: Bugfix: Product ordering function
Post by: beipink on April 12, 2012, 06:28:11 am
If you use sef it"s a mistake in the file and the dev revision is updated.
Without SEF this must work.

Ok, I definetely use SEF, I'll have to give it a go with SEF disabled.
anyway where to i get the ammended file?


[update]
Tried with SEF disabled both in VM and J! and the product ordering still not working in the front end.
With regards to the back-end the arrows require some attnetion too
Title: Re: Bugfix: Product ordering function
Post by: beipink on April 14, 2012, 01:43:32 am
If you use sef it"s a mistake in the file and the dev revision is updated.
Without SEF this must work.

Hi Electrocity,
Is the product ordering working for you?? I cannot get it to work. In the backend posions (nr of the positions) can be changed however the listing of the products remain always the same (both back-end and front-end)
VM2.0.4 J!2.5.5
Title: Re: Bugfix: Product ordering function
Post by: beipink on April 17, 2012, 10:35:41 am
I have updated to VM2.0.6 and ordering in the back-end seems to work now however changes are not reflected in the front-end.
at this point it might be my installation that has a problem. anybody experiencing this sorting/ordering issue in the front-end??
Title: Re: Bugfix: Product ordering function
Post by: miata on April 17, 2012, 12:39:11 pm
The same issue here, the above patch doesn't influence the order on frontend... any idea how to fix this? This seems to be  strange bug for such a popular software and already for years available!?
Title: Re: Bugfix: Product ordering function
Post by: beipink on April 21, 2012, 19:38:27 pm
I have done a fresh install of J2.5.4 and VM2.0.6 and the reordering is not working.
the order nrs can be changed in the back-end however products are always displayed in the same order both in the back-end and front-end as per attached



[attachment cleanup by admin]
Title: Re: PARTIALLY SOLVED: Product ordering function
Post by: beipink on May 03, 2012, 15:27:38 pm
Ordering seems to work, some work is still required but the basics are there.
to order your products you need:
1. filter products by category
2. enter the position nr (arrows do not work as expected yet)
3. hit the  save order icon in the "reorder" column
4. click on configuration/configuration on the right hand side menu
5. then product order settings and select ordering in the drop down list "Default product sort order"

things that still do not work:
1. reordering arrows are inverted (down arrow will increment and up arrow will decrease  the oreder nr)
2. products in the back-end remain in the same position (product_id order) after reordering them. Products should always be listed by sort order. 

Tested on VM 2.6 & J2.5