VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: Novi4ok on May 18, 2016, 16:00:13 PM

Title: How pagination limits products
Post by: Novi4ok on May 18, 2016, 16:00:13 PM
Hello, can you help me, please.

How pagination in category works:

- System gets all products from DB and ather this sets show per page limit?

or:

- System gets products using limit in sql query?


i'm using own product sorting, so i need to replace $this->products array, i have no problems to do it in category template, when pagination is disabled. But when i'm using pagination, i can't get all products array, it shows array with limit. (for example when i set 10 products per page, products array contains 10 products).

Is it possible to get full category products array, replace it and only ather this allow system to show products from this array with pagination.

as i understood, this function are in files:

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

but i still can't find answers to my questions.

Thanks.

P.s. joomla 2.5 + VM  2.0.16c





Title: Re: How pagination limits products
Post by: jenkinhill on May 18, 2016, 23:06:18 PM
Quote from: Novi4ok on May 18, 2016, 16:00:13 PM

P.s. joomla 2.5 + VM  2.0.16c


See http://forum.virtuemart.net/index.php?topic=118683.0

That VM version is over 3 years old, what you want to do may be possible but hardly anybody is going to have such an old version to test with.
Title: Re: How pagination limits products
Post by: Novi4ok on May 19, 2016, 08:58:03 AM
Hello, jenkinhill. Thank you for reply, i will try to update to 2.6.22

So, if it is possible, answer to my questions, please

thank you
Title: Re: How pagination limits products
Post by: GJC Web Design on May 19, 2016, 12:09:07 PM
the var is $nbrReturnProducts and this is set in the vmmodel.php around line 800

if($nbrReturnProducts){
$limitStart = 0;
$limit = $nbrReturnProducts;
$this->_withCount = false;
} else if($this->_noLimit){
$this->_withCount = false;
$limitStart = 0;
$limit = 0;
} else {
$limits = $this->setPaginationLimits();
$limitStart = $limits[0];
$limit = $limits[1];
}
Title: Re: How pagination limits products
Post by: Novi4ok on May 19, 2016, 13:21:29 PM
Quote from: GJC Web Design on May 19, 2016, 12:09:07 PM
the var is $nbrReturnProducts and this is set in the vmmodel.php around line 800

if($nbrReturnProducts){
$limitStart = 0;
$limit = $nbrReturnProducts;
$this->_withCount = false;
} else if($this->_noLimit){
$this->_withCount = false;
$limitStart = 0;
$limit = 0;
} else {
$limits = $this->setPaginationLimits();
$limitStart = $limits[0];
$limit = $limits[1];
}


Thank you.
Yes i saw this function, but it just sets pagination limits, so if i "remove limits" pagination will be removed from category page. I can't understand how this will help me to get all category prudcuts array without removing pagination (in details in first post of thread)

Or i'm not correct?

Title: Re: How pagination limits products
Post by: Studio 42 on May 19, 2016, 14:07:20 PM
Hi,
Do a child class  and force $this->_noLimit in your child class
eg
class customModelProduct extends VirtueMartModelProduct {
....
// overide exeSortSearchListQuery class
public function exeSortSearchListQuery($object, $select, $joinedTables, $whereString = '', $groupBy = '', $orderBy = '', $filter_order_Dir = '', $nbrReturnProducts = false ){
$this->_noLimit = true;
return parent::exeSortSearchListQuery($object, $select, $joinedTables, $whereString , $groupBy ', $orderBy , $filter_order_Dir, $nbrReturnProducts);
}


This is a sample, perhaps you need to adjust it.
Grrets,
Patrick