Show all products on Category page in magento

This was a recent request, I received from client, to show all products in a category at once, instead of showing paging.

there is no such option, available in Admin panel.

so, I decided to rewrite the block, that handles the limit:

app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

Create a namespace, in 'app/code/local' folder with namespace(I go for “Maniac” 😛 ).

Next, create a ‘Catalog’ folder, for our module, under ‘Maniac’ as “app/code/local/Maniac/Catalog”.

Create, another two folders, under the new module folder

app/code/local/Maniac/Catalog/Block

app/code/local/Maniac/Catalog/etc

create config.xml, file in etc, with the following contents:

<?xml version="1.0"?>
<config>

<modules>
<Maniac_Catalog>
<version>0.1.0</version>
</Maniac_Catalog>
</modules>

<global>

<blocks>
<catalog>
<rewrite>
<product_list_toolbar>Maniac_Catalog_Block_Product_List_Toolbar</product_list_toolbar>
</rewrite>
</catalog>
</blocks>

</global>

</config>

Create a Toolbar.php, under "app/code/local/Maniac/Catalog/Block/Product/List/", with the following content:

class Maniac_Catalog_Block_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar {
/**
* Get specified products limit display per page
*
* @return string
*/
public function getLimit() {
$limit = $this->_getData('_current_limit');
if ($limit) {
return $limit;
}

$limits = $this->getAvailableLimit();
$defaultLimit = $this->getDefaultPerPageValue();
if (!$defaultLimit || !isset($limits[$defaultLimit])) {
$keys = array_keys($limits);
$defaultLimit = $keys[0];
}

$limit = $this->getRequest()->getParam($this->getLimitVarName());
if ($limit && isset($limits[$limit])) {
if ($limit == $defaultLimit) {
Mage::getSingleton('catalog/session')->unsLimitPage();
} else {
$this->_memorizeParam('limit_page', $limit);
}
} else {
$limit='all';
}
if (!$limit || !isset($limits[$limit])) {
$limit = $defaultLimit;
}

$this->setData('_current_limit', $limit);
return $limit;
}
}

and voila, here goes all your product on a category page. 🙂

Advertisements

2 thoughts on “Show all products on Category page in magento

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s