Friday, 31 August 2012

joomla getListQuery limit 20 problem

 JModelList::getListQuery - How to expand limit.

I'm using the following code in my Component Model to retrieve my database array

protected function getListQuery()
                // Create a new query object.          
                $db = JFactory::getDBO();
                $query = $db->getQuery(true);
                // Select some fields
                // From the virtuemart product table
                $query->where('product_in_stock >0','product_publish =1');
                return $query;

the problem with this is that it's only return me 20 results at a time.  And I need this to be unlimited.   The solution for this I found in this post JModelList::getListQuery  limits to 20 only
What you need to do is add this code above the function getListQuery
protected function populateState()
        $this->setState('list.limit', 0);

and it'll work like magic :)