VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: usovdm on November 29, 2012, 09:59:09 AM

Title: [SOLVED] Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
Post by: usovdm on November 29, 2012, 09:59:09 AM
Virtuemart 2.0.14.
How test a problem:
0. include standard caching
1. clear a cache
2. come on the 1st page of category 1
3. come on the 1st page of category 2
4. come on the 2nd page of categories 2
5. come on the 1st page of category 1
6. try to come on the 2nd page of category 1, but see on the 1st
Title: Re: Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
Post by: usovdm on November 29, 2012, 10:05:33 AM
VirtueMartControllerCategory - /components/com_virtuemart/contoller/category.php
VirtuemartViewCategory - /components/com_virtuemart/views/category/view.html.php

1. clear a cache
2. come on the 1st page of category 1 (id = 1)
   input: LastVisitedCategoryId input = 0
   page isn't in a cache, therefore VirtueMartControllerCategory::display -> VirtuemartViewCategory::display. Result of execution of VirtuemartViewCategory::display save into a cache.
   in VirtuemartViewCategory::display is followed specifying LastVisitedCategoryId function.
   output: LastVisitedCategoryId output = 1

3. come on the 1st page of category 2 (id = 2)
   input: LastVisitedCategoryId input = 1
   page isn't in a cache, therefore VirtueMartControllerCategory::display -> VirtuemartViewCategory::display. Result of execution of VirtuemartViewCategory::display save into a cache.
   output: LastVisitedCategoryId output = 2

4. come on the 2nd page of categories 2
   input: LastVisitedCategoryId input = 2
   page isn't in a cache, therefore VirtueMartControllerCategory::display -> VirtuemartViewCategory::display. Result of execution of VirtuemartViewCategory::display save into a cache.
   output: LastVisitedCategoryId output = 2

5. come on the 1st page of category 1
   input: LastVisitedCategoryId input = 2
   page is IN a cache, therefore VirtueMartControllerCategory::display -> take from a cache result of VirtuemartViewCategory::display (doesn't execute it). Doesn't changes of LastVisitedCategoryId.
   output: LastVisitedCategoryId output = 2

6. try to come on the 2nd page of category 1, but get on the 1st
   input: LastVisitedCategoryId input = 2
   page isn't in a cache, therefore VirtueMartControllerCategory::display -> VirtuemartViewCategory::display. Since LastVisitedCategoryId doesn't correspond to really open category, throws on the 1st page and result of execution with the wrong navigation of VirtuemartViewCategory::display save into a cache.
   output: LastVisitedCategoryId output = 1 (if the page wasn't cached, on an output have the correct LastVisitedCategoryId therefore for example the 3rd page already fulfills correctly (not for long))

Candidate solution:
Since the controler isn't cached, in / components/com_virtuemart/contoller/category.php at the end of "function display" to add setLastVisitedCategoryId:

public function display($cachable = false, $urlparams = false)  {
if (JRequest::getvar('search')) {
$view = $this->getView('category', 'html');
$view->display();
} else {
// Display it all
$safeurlparams = array('virtuemart_category_id'=>'INT','virtuemart_manufacturer_id'=>'INT','virtuemart_currency_id'=>'INT','return'=>'BASE64','lang'=>'CMD','orderby'=>'CMD','limitstart'=>'CMD','order'=>'CMD','limit'=>'CMD');
parent::display(true, $safeurlparams);
}
if($categoryId = JRequest::getInt('virtuemart_category_id',0)){
shopFunctionsF::setLastVisitedCategoryId($categoryId);
}
}
Title: Re: Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
Post by: Milbo on November 29, 2012, 13:39:31 PM
Thank you very much Usov,

clear explanation and correctly researched. The answer looks very useful, so I add this to vm2.0 and vm2.1
Title: Re: [SOLVED] Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
Post by: zstep on October 28, 2013, 23:58:20 PM
I'm using VM 2.0.24 with Joomla 2.5.9 but still have the same problem as mentioned here when a page cache is enabled.
I have to use JotCache with disabled category view caching now.
Does Virtuemart support whole page caching or not? Is someone experiencing the same problem?
Title: Re: [SOLVED] Pagination problem with cache (Virtuemart 2.0.8 - 2.0.14)
Post by: szbstvn on November 03, 2013, 08:06:04 AM
My problem is same ...

VM 2.0.24 with jotcache


Küldve az én iPad-ről Tapatalk HD használatával