VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: julash on September 13, 2017, 08:18:35 AM

Title: Product next/previous navigation looping
Post by: julash on September 13, 2017, 08:18:35 AM
Hi,

Not sure if this is a bug. Product navigation not working with a loop of same 2 product. I found this problem also on virtuemart demo site. Check http://demo.virtuemart.net/skirt-knock-rock-detail or http://demo.virtuemart.net/cap-baseball-detail and try going next/previous products. At some point both next/previous keep looping in same products.

First found the problem on a website I am developing with virtueMart 3.2.2 and joomla 3.7.4.

Thanks
Julash
Title: Re: Product next/previous navigation looping
Post by: Ventsi Genchev on September 13, 2017, 09:54:22 AM
I can not confirm this. The switching of demo site products works well.
Title: Re: Product next/previous navigation looping
Post by: Jörgen on September 13, 2017, 10:01:07 AM
Hello

I can confirm the faulty behaviour.

Choose cowboy hat and click on next. Now You start looping between Safety helmet nad Cap baseball.
Choose skirt and click on next. Now You start looping between Dress shirt with tie and T-shirt Classic blue.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Product next/previous navigation looping
Post by: Ventsi Genchev on September 13, 2017, 10:23:34 AM
Oh yeah. That's right. Cool.  :)
Title: Re: Product next/previous navigation looping
Post by: Studio 42 on September 13, 2017, 23:49:31 PM
Simply click on "previous" product and you see it loop from H20 Jacket to Skirt to H20 Jacket ....
Title: Re: Product next/previous navigation looping
Post by: Milbo on October 23, 2017, 13:37:13 PM
The problem is here, that the ordering must be correctly determined, else you get this effect. It is very hard to avoid it. The real solution would be an own temporary list keeping the product order. Please check the demo here http://demo.virtuemart.net/ghd-2-07-detail

The reason is, that any call to the db is new and has no knowledge about the last. So the real order can differ from call to call. The sql executes the same as for the browsing view, just with an extra filter, which excludes the current product.
Title: Re: Product next/previous navigation looping
Post by: shyntaxx on May 29, 2019, 09:55:04 AM
Hi,

I am not sure if I understand the solution here .. Could you please explain a littlebit more .. ? Whats should I do in order so the product navigation won't between two items ?

I am using Joomla! 3.9.6 | VirtueMart 3.4.2 | Shaper_helix3 template

Best regards.
Title: Re: Product next/previous navigation looping
Post by: shyntaxx on May 29, 2019, 10:01:31 AM
Okay I've just solved it by setting:

Default product sort order: Product name
Default category sort order: Ordering, Name

It doing its job now properly!
Title: Re: Product next/previous navigation looping
Post by: pellegrinoL on June 05, 2019, 11:10:05 AM
Hi,

I am having the same issue, I have set category order "price ascending" and also in the product category I have ordered by price (see Pic) but after some products, there is the loop between the 2 products...

Is there any possibility to solve it?

Best

I am using:
J: 3.8.13
VM: 3.4.3 10005
Title: Re: Product next/previous navigation looping
Post by: pellegrinoL on June 17, 2019, 10:06:36 AM
Hi If i use the solution proposed by shyntaxx
Quote from: shyntaxx on May 29, 2019, 10:01:31 AM
Okay I've just solved it by setting:

Default product sort order: Product name
Default category sort order: Ordering, Name

It doing its job now properly!


It works, but I would order the products in the category by price and not by name. When I change this option, there is again the loop.
Title: Re: Product next/previous navigation looping
Post by: Studio 42 on June 17, 2019, 13:18:51 PM
The problem is that code used by Virtuemart. It need a little more complex query but the team dont try to solve this since now many years.
Title: Re: Product next/previous navigation looping
Post by: pellegrinoL on June 18, 2019, 10:02:20 AM
Many thanks for answering!
Title: Re: Product next/previous navigation looping
Post by: StefanSTS on June 18, 2019, 11:05:33 AM
There might be the possibility to push that feature with a VirtueMart Supporter Membership.

There is so much work going on that some features just get put on a hold, if the main function - that is mostly used - works.

That membership thing worked in the past for my customers, so you might just ask iStraxx or send them a ticket at extensions.virtuemart.net.

Regards
Stefan
Title: Re: Product next/previous navigation looping
Post by: subn3t on October 09, 2022, 13:50:31 PM
Quote from: pellegrinoL on June 05, 2019, 11:10:05 AM
Hi,

I am having the same issue, I have set category order "price ascending" and also in the product category I have ordered by price (see Pic) but after some products, there is the loop between the 2 products...

Is there any possibility to solve it?

Best

Same problem here. This fix does not work for me. Any ideas guys?

Joomla 3.10.11
VirtueMart 4.0.6 10690
Title: Re: Product next/previous navigation looping
Post by: GJC Web Design on October 09, 2022, 17:03:46 PM
this post is from 2019!!!!!!!!!!!!
Title: Re: Product next/previous navigation looping
Post by: hazael on October 09, 2022, 17:46:47 PM
Quote from: GJC Web Design on October 09, 2022, 17:03:46 PM
this post is from 2019!!!!!!!!!!!!
Don't pick on them. A group of archaeologists came to our forum :D
Title: Re: Product next/previous navigation looping
Post by: subn3t on October 27, 2022, 14:53:24 PM
Quote from: hazael on October 09, 2022, 17:46:47 PM
Quote from: GJC Web Design on October 09, 2022, 17:03:46 PM
this post is from 2019!!!!!!!!!!!!
Don't pick on them. A group of archaeologists came to our forum :D

So you do not have a solution, but spare time to loose.
As I said I have the same problem and the "fix" does not work. Do I have to open new topic and explain the same things that are already said by others?
Title: Re: Product next/previous navigation looping
Post by: Milbo on October 27, 2022, 15:24:41 PM
There is no need to open a new post. I gave an answer already and that answer is still valid.

Quote from: Milbo on October 23, 2017, 13:37:13 PM
The problem is here, that the ordering must be correctly determined, else you get this effect. It is very hard to avoid it. The real solution would be an own temporary list keeping the product order. Please check the demo here http://demo.virtuemart.net/ghd-2-07-detail

The reason is, that any call to the db is new and has no knowledge about the last. So the real order can differ from call to call. The sql executes the same as for the browsing view, just with an extra filter, which excludes the current product.


No one cared to fix it, right. Looks like the problem is just too light to expend money on it. Someone can fix it and provide a patch, great we will take it. But it is just not an urgent problem. If it is that urgent, fix it, or pay someone to fix it and donate the code as many other people already did the years before. This is an opensource project! If you want bugs fixed, do it, or pay for it, or ... keep silent. Ranting is the wrong way to get things done.
Title: Re: Product next/previous navigation looping
Post by: subn3t on October 27, 2022, 18:23:07 PM
I definitely agree. But just asking if there is anyone with a solution is not a reason for someone елсе to pick on me. We'll fix it ourselves. Thanks!
Title: Re: Product next/previous navigation looping
Post by: Milbo on October 27, 2022, 21:44:32 PM
lol. You did not just ask for a solution. Anything is written down, anyone can read it. It is absolutly okey to bump an old post. It is even intended, well done. But we hate the attitude "Hey that was reported x months, years ago and it got not fixed, what a shit here".
First: No one here has to fix a bug for anyone. Currently there are 2 ways how bugs are fixed. Either a community member comes with a bug fix, or I do the bug fix. So as you can imagine, most bugs are just reported without solution and so I do the fix. But why I am doing the fix? For my members customers and paying members https://extensions.virtuemart.net/support-updates/virtuemart-membership

But even for a silvermembereship, I would say "Sorry, I cannot fix this for 100 euro".
Title: Re: Product next/previous navigation looping
Post by: subn3t on October 27, 2022, 22:47:16 PM
Quote from: Milbo on October 27, 2022, 21:44:32 PM
lol. You did not just ask for a solution. Anything is written down, anyone can read it. It is absolutly okey to bump an old post. It is even intended, well done. But we hate the attitude "Hey that was reported x months, years ago and it got not fixed, what a shit here".
First: No one here has to fix a bug for anyone. Currently there are 2 ways how bugs are fixed. Either a community member comes with a bug fix, or I do the bug fix. So as you can imagine, most bugs are just reported without solution and so I do the fix. But why I am doing the fix? For my members customers and paying members https://extensions.virtuemart.net/support-updates/virtuemart-membership

But even for a silvermembereship, I would say "Sorry, I cannot fix this for 100 euro".

And this is why we will fix the issue and we will give the solution to everyone for free. Got it, Mr. Admin?
Title: Re: Product next/previous navigation looping
Post by: Milbo on October 27, 2022, 23:22:09 PM
That sounds great :-). But your first answer sounded for me more or less "passiv-agressive"
Quote from: subn3t on October 27, 2022, 18:23:07 PM
...We'll fix it ourselves. Thanks!

I try to give you more information about the problem, hints how it could be solved.
First the problem does imho not exist, if you set a fixed ordering to the products. I mean the ordering column. The problem arises because there are a lot entries with same "weight" in the ordering or better sorting priority.
So lets say we want to sort for "ordering". The numbers you can set as ordering, if you select a category. Most case, any number is 0 and so mysql uses more than one method to return them. What I mean is, the order is not always different, but switches between 2-4 sets. So if we add a ordering number to any product, anything works fine. Just that you get the real problem behind that. I invested really many hours in it already, weeks!
The sql reflects exactly the current set sql in "sortSearchListQuery". We lightened the problem already by using mixed sorting, for example "pc.ordering,product_name". If no ordering is set, use the name.

Check the product model, the function sortSearchListQuery and there around line 701, there you see my current solution for it. I added as secondary sorting at least the p.`virtuemart_product_id`, so it should work now.

Maybe you and/or your team finds here and there a better sorting. Imho there is the most potential to enhance it without too much hazzle. But if this does not work, the next idea is a temporarly sorting, with an extra column per sorting option.
"ordering_prices","ordering_productname", and so on. The next step is to use only the generated ordering and to generate it if not there, and also to remove it, if outdated. if this should be part of the core, it needs something which decides, which sorting tables to add. and so on. Following this paths means really a week of work or more.
But it would be also very interesting, because it would allow sorting for prices with calculation rules, a very demanded feature. Not added yet, because it would mean cached tables and that means just a lot of work. Not really hard, but a lot of work hehe, I like more the hard stuff,...
Title: Re: Product next/previous navigation looping
Post by: Studio 42 on October 28, 2022, 11:05:02 AM
This is the solution i use for my own component in products


public function neighbors(){

$this->setVars();
$left ='';
$select = '';
$ordering = $this->ordering;
$oName = $ordering;
$whereOrdering = $ordering;
if($pos = strpos($oName, '.')) $oName = substr($oName,$pos+1);
// echo $pos;
$oName = $this->db->quote($this->item->$oName);
if($this->ordering === 'pc.ordering') {
$left = ' LEFT JOIN `#__virtuemart_product_categories` pc on pc.virtuemart_product_id = p.virtuemart_product_id';
}else if($this->ordering === 'stock') {
$select = ',product_in_stock-product_ordered as stock';
$whereOrdering = 'product_in_stock-product_ordered';
}
$q = 'SELECT l.product_name,l.virtuemart_product_id '.$select.' FROM `#__virtuemart_products` p
LEFT JOIN `#__virtuemart_products_'.VMLANG.'` l on l.virtuemart_product_id = p.virtuemart_product_id'.
$left.'
WHERE ('.$whereOrdering.'='.$oName.'
and p.virtuemart_product_id < '.$this->db->quote($this->item->virtuemart_product_id).') OR
'.$whereOrdering.'<'.$oName.'
GROUP BY p.virtuemart_product_id ORDER BY '.$this->ordering.' DESC, p.virtuemart_product_id DESC limit 0,1';
// echo $q;return;
$this->db->setQuery ($q);
$this->before = $this->db->loadObject();
$q = 'SELECT l.product_name,l.virtuemart_product_id '.$select.' FROM `#__virtuemart_products` p
LEFT JOIN `#__virtuemart_products_'.VMLANG.'` l on l.virtuemart_product_id = p.virtuemart_product_id'.
$left.'
WHERE ('.$whereOrdering.'='.$oName.'
and p.virtuemart_product_id > '.$this->db->quote($this->item->virtuemart_product_id).') OR
'.$whereOrdering.'>'.$oName.'
GROUP BY p.virtuemart_product_id ORDER BY '.$this->ordering.' ASC, p.virtuemart_product_id ASC limit 0,1';
$this->db->setQuery ($q);
$this->after = $this->db->loadObject();
}


Check the queries, i do not removed the code, so you can understand the names in the query
Title: Re: Product next/previous navigation looping
Post by: Studio 42 on October 28, 2022, 11:08:54 AM
Oups, i forgot to say that it work always and tested many times in more then 10 shops i manage. I use this component all days
Title: Re: Product next/previous navigation looping
Post by: hazael on October 30, 2022, 13:13:59 PM
I recently tested the commercial plugin "vmuikit x"  from joomlapro. The funny thing is that this plugin also has this option that you can run on the product page - it can only display 3 products in a loop from a category that has hundreds of them: D
If someone says that it is impossible to run normally, how is it that other components do not have a problem with it?
Title: Re: Product next/previous navigation looping
Post by: Studio 42 on October 31, 2022, 17:50:14 PM
Hazael, check my code. It can work for  or any number of products