Author Topic: How pagination limits products  (Read 2641 times)

Novi4ok

  • Beginner
  • *
  • Posts: 3
  • A beginner
How pagination limits products
« 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


 



jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27572
  • Always on vacation
    • Jenkin Hill Internet
Re: How pagination limits products
« Reply #1 on: May 18, 2016, 23:06:18 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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.6.8 10204 on Joomla 3.9.13 PHP 7.0.33

Novi4ok

  • Beginner
  • *
  • Posts: 3
  • A beginner
Re: How pagination limits products
« Reply #2 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

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9195
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How pagination limits products
« Reply #3 on: May 19, 2016, 12:09:07 pm »
the var is $nbrReturnProducts and this is set in the vmmodel.php around line 800

Code: [Select]
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];
}
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Novi4ok

  • Beginner
  • *
  • Posts: 3
  • A beginner
Re: How pagination limits products
« Reply #4 on: May 19, 2016, 13:21:29 pm »
the var is $nbrReturnProducts and this is set in the vmmodel.php around line 800

Code: [Select]
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?


Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4046
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: How pagination limits products
« Reply #5 on: May 19, 2016, 14:07:20 pm »
Hi,
Do a child class  and force $this->_noLimit in your child class
eg
Code: [Select]
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