News:

Support the VirtueMart project and become a member

Main Menu

Product next/previous navigation looping

Started by julash, September 13, 2017, 08:18:35 AM

Previous topic - Next topic

hazael

#15
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

subn3t

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?

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

subn3t

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!

Milbo

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".
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

subn3t

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?

Milbo

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,...
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

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

Studio 42

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

hazael

#24
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?

Studio 42

Hazael, check my code. It can work for  or any number of products