VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Wedal on July 08, 2022, 12:52:51 PM

Title: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Wedal on July 08, 2022, 12:52:51 PM
VirtueMart 4.0.6 10690 + Joomla 4.1.5

There are 2 problems with pagination in VM:

1) VM category pagination shows the same link for all pages. The problem leads to the VM router.

Quick fix:
/components/com_virtuemart/router.php

Before:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
} else if ( $start>0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
}


After:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
//} else if ( $start>0 ) {
} else if ( $limitstart > 0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
//$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
$segments[] = self::lang('results') .','. ($limitstart + 1).'-'.($limitstart + $limit);
}


Also for some reason the $limit here is not the same as the one found in vmpagination.php. It breaks the order of the results.

Quick fix:
/administrator/components/com_virtuemart/helpers/vmpagination.php

Before:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset);

After:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset .'&limit='.$this->limit);

This is probably a bad solution, but it's the fastest I could dig up.


2) Joomla 4 uses new pagination layouts:
/layouts/joomla/pagination

The VM is looking for an overridden pagination layout at the old address:

$chromePath = VMPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php';

Is it possible to make the VM use the Joomla 4 pagination overrides (/templates/our_template/html/layouts/joomla/pagination)?
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: tonis on August 29, 2022, 13:40:11 PM
Quote from: Wedal on July 08, 2022, 12:52:51 PM
VirtueMart 4.0.6 10690 + Joomla 4.1.5

There are 2 problems with pagination in VM:

1) VM category pagination shows the same link for all pages. The problem leads to the VM router.

Quick fix:
/components/com_virtuemart/router.php

Before:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
} else if ( $start>0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
}


After:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
//} else if ( $start>0 ) {
} else if ( $limitstart > 0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
//$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
$segments[] = self::lang('results') .','. ($limitstart + 1).'-'.($limitstart + $limit);
}


Also for some reason the $limit here is not the same as the one found in vmpagination.php. It breaks the order of the results.

Quick fix:
/administrator/components/com_virtuemart/helpers/vmpagination.php

Before:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset);

After:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset .'&limit='.$this->limit);

This is probably a bad solution, but it's the fastest I could dig up.


Thank you for this fixes! I was also stucked with this bugs. Hopefully it will be ok in new version.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Milbo on August 31, 2022, 00:02:11 AM
Thank you for your fix. But I am not sure if it is the right way. I need to dig into it deeper. Do you mean the pagination of categories? or of products in categories?

Quote
2) Joomla 4 uses new pagination layouts:
/layouts/joomla/pagination
do you mean /templates/our_template/html/layouts/joomla/pagination.php ? I was already adding that, a check first on the other place. But I need to know it exactly, could be also /templates/our_template/html/layouts/joomla/pagination/pagination.php.

and I dont use any template with this override. The default joomla template (CAssiopeia) does not have it.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Wedal on August 31, 2022, 09:19:54 AM
Hi Milbo,

QuoteThank you for your fix. But I am not sure if it is the right way. I need to dig into it deeper. Do you mean the pagination of categories? or of products in categories?
Products in categories.

Quotedo you mean /templates/our_template/html/layouts/joomla/pagination.php ? I was already adding that, a check first on the other place. But I need to know it exactly, could be also /templates/our_template/html/layouts/joomla/pagination/pagination.php.

and I dont use any template with this override. The default joomla template (CAssiopeia) does not have it.
Not pagination.php, but new Joomla 4 pagination layouts: list.php, links.php, link.php.

The idea is to use unified Joomla pagination layouts for VM. Now if we need to make changes to the pagination of the site (for example, change the arrow icons classes), we need to do it separately for the Joomla and VM pagination layouts, since the pagination layouts have been changed in J4 (split into three files).



Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Darko F. on August 31, 2022, 14:13:09 PM
Hi,
I'm using Joomla 4.2.1 and  VirtueMart 4.0.6 10690

Can confirm pagination don't work in category and also not in subcategory.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: veselinovm on September 08, 2022, 15:04:11 PM
I am using VM: 3.8.6 and Joomla 3.10.11
Pagination is not working well with fix tonis.
When you have to get back to first page, shows products of first page, but selected pagination stays on last number.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: tonis on September 09, 2022, 22:20:19 PM
Quote from: veselinovm on September 08, 2022, 15:04:11 PM
I am using VM: 3.8.6 and Joomla 3.10.11
Pagination is not working well with fix tonis.
When you have to get back to first page, shows products of first page, but selected pagination stays on last number.

Hi, maybe because ist not the same version. On the 4. versions its working (at least for me).
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: hazael on September 10, 2022, 11:52:49 AM
Quote from: tonis on September 09, 2022, 22:20:19 PM
Hi, maybe because ist not the same version. On the 4. versions its working (at least for me).
Set the category with the product listing as the home page of your site. Then you may notice that it doesn't work.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: tomis on September 24, 2022, 15:15:19 PM
Before:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
} else if ( $start>0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
}


After:

if ($start !== null &&  $limitstart!== null ) {
if(vmrouterHelper::$debug) vmdebug('Pagination limits $start !== null &&  $limitstart!== null',$start,$limitstart);
//$segments[] = self::lang('results') .',1-'.$start ;
//} else if ( $start>0 ) {
} else if ( $limitstart > 0 ) {
//For the urls leading to the paginated pages
// using general limit if $limit is not set
if ($limit === null) $limit= vmrouterHelper::$limit ;
//$segments[] = self::lang('results') .','. ($start+1).'-'.($start+$limit);
$segments[] = self::lang('results') .','. ($limitstart + 1).'-'.($limitstart + $limit);
}


Also for some reason the $limit here is not the same as the one found in vmpagination.php. It breaks the order of the results.

Quick fix:
/administrator/components/com_virtuemart/helpers/vmpagination.php

Before:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset);

After:
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset .'&limit='.$this->limit);

Virtuemart 4.0.6. + Joomla 4.2.2

The pagination fix works partially. Back to page 1 not working. Any fix?
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: creationell on November 17, 2022, 15:30:37 PM
Quote from: tomis on September 24, 2022, 15:15:19 PM
Virtuemart 4.0.6. + Joomla 4.2.2

The pagination fix works partially. Back to page 1 not working. Any fix?

For version VM 4.0.6 + Joomla 4.1.5.

We "fixed" the problem with coming back to page one in this way:

/administrator/components/com_virtuemart/models/product.php

Line 1024:

Before:
$limitStart = vRequest::getInt ('limitstart', 0,'GET'); $app->getUserStateFromRequest ($limitStartString, 'limitstart', vRequest::getInt ('limitstart', 0,'GET'), 'int');

After:
$limitStart = vRequest::getInt ('limitstart', 0,'GET'); //$app->getUserStateFromRequest ($limitStartString, 'limitstart', vRequest::getInt ('limitstart', 0,'GET'), 'int');

Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: kiro789 on November 18, 2022, 14:54:31 PM
I can confirm too, the pagination don't work for products in category layout.
When you have to get back to first page or previous page, shows products of first page, but selected pagination stays on last number.
VirtueMart 4.0.7 10744 with Joomla 4.2.5.

Regards!
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: kiro789 on November 28, 2022, 07:49:55 AM
The problem actually is the return results to 1-page and the url: /results,1-0.html
When you are on products in category.
When you go back from page 10 to 2 fo example - no problems.
When you want to go back from 10 to 1 here is the problem.
In the url is missig the /results,1-0.html and shows only .html and shows products from page 10.

Regards!
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: GJC Web Design on November 28, 2022, 10:16:00 AM
tried https://dev.virtuemart.net/attachments/download/1343/com_virtuemart.4.0.8.10748.zip ?  the next stable
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: kiro789 on November 29, 2022, 06:40:26 AM
Yes, instaled the 4.0.8 10748. The same problem. Returns to page 1 don't works.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: hazael on November 29, 2022, 12:22:14 PM
Quote from: kiro789 on November 29, 2022, 06:40:26 AM
Yes, instaled the 4.0.8 10748. The same problem. Returns to page 1 don't works.
It doesn't work because your browser remembered the limit=''  variables from a different category which is different from the one you are using on the current page.
The current solution will never work on the homepage of domain.

Use only one value for your limit variable for all categories. It's best to remove the select option from the form in the template, which allows you to change the display of the number of products on one page.

A simple workaround is to add the selected category to the Joomla menu. At the end of the URL, you just need to manually add &limistart=0
Do as in the attached picture and your problem will disappear.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix [solved]
Post by: kiro789 on November 29, 2022, 14:58:13 PM
Hi, the link you show me can not be changed in joomla.
And don't mean the home page, I mean the category pages.
Look here for example:
https://joomla4.baron.bg/%D0%B8%D0%B7%D0%BA%D1%83%D1%81%D1%82%D0%B2%D0%B5%D0%BD%D0%B8-%D1%80%D0%B0%D1%81%D1%82%D0%B5%D0%BD%D0%B8%D1%8F.html

Regards!
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: hazael on November 29, 2022, 18:52:09 PM
Haha. Yes! Of course you can change it in joomla!!!  ;D
Anyone can do it - you don't need to be a PhD in programming.
Sorry... Does a modern computer scientist always have to be led by the hand? ;)

In your browser, in the source code edition of this locked field, remove the "readonly" attribute.
After the change, add &=limitstart=0 at the end and save this item in the menu. That's all  8)

P.S.
My trivial solution also eliminates the problem of categories on the home page, which is why I also wrote about it

Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: kiro789 on November 30, 2022, 10:04:45 AM
Hi, When I remove the  "readonly" attribute in the browser, I am able to edit the link, but when I save it just do not add the &=limitstart=0 at the end.

Regards!
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Jörgen on November 30, 2022, 13:58:08 PM
Quote
After the change, add &=limitstart=0 at the end and save this item in the menu. That's all  8)

I may understand this wrong, but I think Hazael said you should add it , notice that Hazaels post had a typo, should be:  &limitstart=0

Jörgen
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: kiro789 on November 30, 2022, 15:17:47 PM
I add this in the link &=limitstart=0
But when I save it returns the
index.php?option=com_virtuemart&view=category&virtuemart_category_id=126&virtuemart_manufacturer_id=0&clearCart=0

and not

index.php?option=com_virtuemart&view=category&virtuemart_category_id=126&virtuemart_manufacturer_id=0&clearCart=0&=limitstart=0
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: hazael on November 30, 2022, 23:24:44 PM
you are typing wrong: &=limitstart=0
It should be added: &limitstart=0

Don't add it in the HTML editor.
After removing the "readonly" attribute, the form field will be unlocked - enter this value at the end in field name: "Link". Finally, press the "save" button.
This works 100% in the Edge browser. I not tested it with other browsers
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Jörgen on December 01, 2022, 07:15:37 AM
Hello Hazael

I copied your post and did not notice that you had spelled this wrong, have edited my former post now.

Jörgen
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix [solved]
Post by: kiro789 on December 02, 2022, 05:58:37 AM
Hello,
Thank you very much!!  :)
Works 100% in the Edge browser, but in Chrome didn't works.

Regards!
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Jörgen on December 02, 2022, 09:42:21 AM
Nice to hear that you got it working.

Marked topic as solved.

Jörgen
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Milbo on December 02, 2022, 21:14:23 PM
Guys, can you imagine that? Any new bigger joomla release, we have this trouble with the 0.

I think the solution is in the xml of the view. Maybe we must add the limitstart to the fieldset Request? Then we set it hidden and to 0.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: hazael on December 02, 2022, 23:50:00 PM
The category displays random pagination results - compare attachment A and B.
And this is not Joomla 4 - it's version 3

After opening the category, the same pagination shows 2 different results. You can't go back to the homepage with the first click, but you can with the second. When I add to the main menu Limitsart=0 in category URL this problem disappears.
Virtuemart is the only component that has a problem with this - maybe several years?  :o

Every now and then someone reports that pagination doesn't work and you keep denying it. It's kind of absurd  ;D

Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: hazael on December 03, 2022, 00:04:56 AM
Same problem with this weird and useless &clearCart=0
In one menu it shows up in URL and I have no way to remove it, and in another menu of the same component it is no longer there.
It is similar with Itemid - one product belonging to one category in its address may have different Itemids...

Probably the biggest problem is modules - for example mod_virtuemart_category - Depending on where it will display the product categories, the URL has a different Itemid.
And then someone writes that - "my access to the category is forbidden" ;)

This solution multiplies a large number of unnecessary duplicates in the database, in the website and browser memory files.
I'm testing a 4SEF component - in database has accumulated 100 000 unnecessary various duplicate links. But the store only has 2 200 products.  :o
This is very very suboptimal
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Milbo on December 04, 2022, 19:56:20 PM
lol, you are the first who says, that the pagination does not work in general. The thread started with an adjustments for the SEO of j4.

But I doubt that other do not have the described problem. Do sql yourself and you will understand. If your ordering/sorting is not determined, you get different sequences. It is the same with getNeighboured products.

It makes not really fun to answer all this different mixed problems.

"with this weird and useless &clearCart=0" There you see a big problem with the communication here. This is a community and if there is a an option clearCart it is definitly not useless. Someone invested time, money and so on to get it into the core.

So the problem is not that it is useless, the problem is, that it sometimes appears in the URL, and sometimes not. So instead of talking about, how to remove the bug, that the clearCart is shown, we talk about if the feature is useless. Do you get it?

Same with itemid and so on. Solve the mistery and we can create a fix. So long no one could tell me, why that happens.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: sandomatyas on December 16, 2022, 16:33:44 PM
About the pagination issue:
Adding limitstart=0 to the url seems a working solution for us.
As Milbo suggested, I added <field name="limitstart" type="hidden" default="0" /> to the first fieldset of components/com_virtuemart/views/category/tmpl/default.xml and opened/saved all of VM category menu items. As far as I can see, it does work well.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Milbo on December 20, 2022, 21:48:46 PM
I think I added that in the last release (VM4.0.12). But I am not certain. But thank you for testing, that is a new "grib" to solve the problem.
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: kiro789 on December 21, 2022, 07:25:44 AM
Hi,
For me is not working with VirtueMart 4.0.12 10777
The currently installed Joomla! version is "‎4.2.6"‎

Regards!
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: sandomatyas on December 21, 2022, 13:28:16 PM
Quote from: Milbo on December 20, 2022, 21:48:46 PM
I think I added that in the last release (VM4.0.12). But I am not certain. But thank you for testing, that is a new "grib" to solve the problem.

I don't see any change in the xml
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Milbo on January 09, 2023, 11:18:36 AM
Right, thank you. Added
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: hazael on January 10, 2023, 21:19:09 PM
The last version works very well.
Thanks Milbo
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: kiro789 on January 11, 2023, 07:43:28 AM
Is that the latest version:
com_virtuemart.4.0.12.10777

https://dev.virtuemart.net/projects/virtuemart/files
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: Milbo on January 11, 2023, 21:51:05 PM
It is almost the last version. I just committ the new changes, for the real last version (which already circles as test versions)
Title: Re: [VM 4.0.6] - Pagination bug in VM router & quick fix
Post by: kiro789 on March 16, 2023, 17:04:29 PM
Hi,
Where can I download the latest version with edited xm

Regards!