Bill Rust
Bill Rust

Reputation: 141

Magento - Limit number of products returned on specific pages?

I have some specific pages I am linking to from this page - http://www.formagdev1.com/shop-online.html

Top of page, New to the store and Customer Favorites both link to custom pages, but we'd like to limit the # of products displayed on those pages. Exclusive is fine, it can return a page with pagination as it currently does.

So if you click on New to the store, you'll get to a page that dumps an array with all the products with pagination. I would like to limit the amount of products on this page to 25, with no pagination. Same with Customer Favorites page.

I am using Grid Mode only, and the code I have currently building the array is -

    <?php $_collectionSize = $_productCollection->count();  ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
    <?php if ($i++%$_columnCount==0): ?>
    <ul class="products-grid">
    <?php endif ?>

The issue I am having is, if I just remove the toolbar top and bottom from the custom page, it removes it from ALL list of grid type pages, so the simple idea in this case doesn't seem to be working.

Is there a way to limit the number of products shown to 25 for these 2 specific pages, with NO pagination?

Any ideas?

Thanks! Bill

Upvotes: 0

Views: 897

Answers (3)

Bill Rust
Bill Rust

Reputation: 141

Thanks for the suggestions everyone. I ended up just doing this using XML in the deisng of the page, workes as I need it to now :-)

Upvotes: 0

Lucas Moeskops
Lucas Moeskops

Reputation: 5443

Mage_Catalog_Block_Product_List is the Block that handles the list display. You could add a function here that defines if this is a no pagination category, say function isNoPagination(). You can then edit the catalog/product/list.phtml template to only display the toolbar when !$this->isNoPagination() and set max collection size to 25 when !$this->isNoPagination().

The function isNoPagination could be based on for example getLayer()->getCategoryId().

Upvotes: 0

nethead
nethead

Reputation: 480

Try limit $collection with:

->setPage(1, 25) 

But works only if collection not already initialized.

Upvotes: 1

Related Questions