Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

change default number of items showing in grid/list view
 
kris
Jr. Member
 
Total Posts:  11
Joined:  2007-09-30
NZ
 

Hi,

Can anyone please help me in figuring out how to change the default number of items showing in the catalog listings .

For a template I would like to get rid of the toolbar. To be able to do so I need to be able to load all products automatically not just the 5 or 9 which are the default values for list and grid view.

I am fairly sure this file needs to be edited:
/app/design/frontend/default/default/template/catalog/product/list.phtml

I have already tried using variations of

<?$_productCollection=$this->getLoadedProductCollection()?>
<?$_productCollection
->setPageSize('25')?>

Unfortunately that only fools the pager into thinking all items are loaded, when in fact only the default number is

Trying with

<?$_productCollection=$this->getCollection()?>

Gives a fatal error: Call to a member function getSize() on a non-object further down when checking the size of the collectiom.

Cheers for your help

 
Magento Community Magento Community
Magento Community
Magento Community
 
__pete®
Jr. Member
 
Total Posts:  11
Joined:  2007-11-22
 

have a look at:
app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php

public function getAvailableLimit()
    
{
        
if ($this->getCurrentMode() == 'list'{
            
return array(8=>8,16=>16,24=>24,32=>32,40=>40'all'=>__('All'));
        
}
        
elseif ($this->getCurrentMode() == 'grid'{
            
return array(8=>8,12=>12,16=>16,20=>20'all'=>__('All'));
        
}
        
return parent::getAvailableLimit();
    
}

here you can change the defaults wink the first one is the one beein apllied on entering the page.

_pete®

 
Magento Community Magento Community
Magento Community
Magento Community
 
kris
Jr. Member
 
Total Posts:  11
Joined:  2007-09-30
NZ
 

not intuitive but works a charm - thanks _pete®

 
Magento Community Magento Community
Magento Community
Magento Community
 
WhoIsGregg
Member
 
Total Posts:  64
Joined:  2008-09-02
Tampa, Florida
 

Unfortunately the user can override this by choosing a lower quantity limit from any normal category page… You can test this by going to a “normal” category page, switching to list view and choosing “limit 5” then going back and reloading the page that uses the category view that requires more than 5 products. Only five will appear. User preferences set in the session appear to beat all other settings.

So, you still need a way to force override the limit on template pages that don’t show a toolbar.

Unfortunately, I haven’t figured out how to do that yet. :/

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ralf Bernert
Jr. Member
 
Total Posts:  13
Joined:  2008-07-18
 

I found the solution for the problem.. it’s pretty simple.. just use the following line of code

$tempLimit 12;
<?php Mage::getSingleton('catalog/session')->setLimitPage($tempLimit); ?>

before

<?$_productCollection=$this->getLoadedProductCollection()?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
jspicher
Jr. Member
 
Total Posts:  15
Joined:  2010-08-02
 

Attack of the zombie thread run!!!

Seriously though, where would l put Ralf’s snippet (what template file that is)?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
annie987
Jr. Member
 
Total Posts:  16
Joined:  2009-05-20
 

Fantastic!  Works like a dream, thank you!

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

Isn’t there a Backend configuration for limiting the values in product listing?
I think yes:
System > Configuration > Catalog > Frontend > here it goes…
Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
tbradley22
Member
 
Total Posts:  45
Joined:  2011-01-27
 

best way to do it is with the configuration settings (as described above) or catalog.xml. some themes use configuration settings others don’t.

one note if you’re using catalog.xml is that if your “setDefaultGridPerPage” value is set to a valute that is not listed as one of the “addPagerLimit” values then the system won’t pay any attention to it.

<!-- The following code shows how to set your own pager increments -->
                        <
action method="setDefaultListPerPage"><limit>10</limit></action>
                        <
action method="setDefaultGridPerPage"><limit>9</limit></action>
                        <
action method="addPagerLimit"><mode>list</mode><limit>10</limit></action>
                        <
action method="addPagerLimit"><mode>list</mode><limit>20</limit></action>
                        <
action method="addPagerLimit"><mode>list</mode><limit>30</limit></action>
                        <
action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                        <
action method="addPagerLimit"><mode>grid</mode><limit>9</limit></action>
                        <
action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
                        <
action method="addPagerLimit"><mode>grid</mode><limit>18</limit></action>
                        <
action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>

ted
design and seo

 
Magento Community Magento Community
Magento Community
Magento Community
 
tbradley22
Member
 
Total Posts:  45
Joined:  2011-01-27
 

best way to do it is with the configuration settings (as described above) or catalog.xml. some themes use configuration settings others don’t.

one note if you’re using catalog.xml is that if your “setDefaultGridPerPage” value is set to a valute that is not listed as one of the “addPagerLimit” values then the system won’t pay any attention to it.

<!-- The following code shows how to set your own pager increments -->
                        <
action method="setDefaultListPerPage"><limit>10</limit></action>
                        <
action method="setDefaultGridPerPage"><limit>9</limit></action>
                        <
action method="addPagerLimit"><mode>list</mode><limit>10</limit></action>
                        <
action method="addPagerLimit"><mode>list</mode><limit>20</limit></action>
                        <
action method="addPagerLimit"><mode>list</mode><limit>30</limit></action>
                        <
action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                        <
action method="addPagerLimit"><mode>grid</mode><limit>9</limit></action>
                        <
action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
                        <
action method="addPagerLimit"><mode>grid</mode><limit>18</limit></action>
                        <
action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>

ted
design and seo

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top