Magento Toolbar – View All Products Only Shows 3 Products

pagertoolbar

I´m having the issue that if I click "View all" products in my toolbar then what I get back is a category page with the limit of 3 products instead of all.

I have checked and I think I know where the issue is but I can´t resolve it.
If i set the pager to all (in total 500 products)

$_collectionSize = $_productCollection->getSize(); // returns 500
$_collectionSize = $_productCollection->count(); //returns 3

If I set the pager to 200

$_collectionSize = $_productCollection->getSize(); // returns 200
$_collectionSize = $_productCollection->count(); //returns 200

What could be the issue?

Update

I have

$_collectionSize = $_productCollection->count();
echo $_productCollection->getSelect()->__toString();

And for every numerical limit set in the frontend of the category page I get an SQL query back

SELECT `e`.*, `cat_index`.`position` AS `cat_index_position'.......
ORDER BY `publishingdate` desc LIMIT 6 

Limit changes all the time depending on the Limit I set in the Pager Toolbar
but if I click on 'All' then I get this

ORDER BY `publishingdate` desc LIMIT 3

Update
I have not changed the function or anything for the limit, I just add the limits in the backend. So the function to set the limit etc. would be as usual

<div class="pager">
    <p class="amount">
        <?php if($this->getLastPageNum()>1): ?>
            <?php echo $this->__('Books %s-%s of %s', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
        <?php else: ?>
            <?php echo $this->__('%s Book(s)', $this->getTotalNum()) ?>
        <?php endif; ?>
    </p>

    <div class="limiter">
        <label><?php echo $this->__('Show') ?></label>
        <select onchange="setLocation(this.value)">
        <?php foreach ($this->getAvailableLimit() as  $_key=>$_limit): ?>
            <option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
                <?php echo $_limit ?>
            </option>
        <?php endforeach; ?>
        </select> <?php echo $this->__('per page') ?>

    </div>

    <?php echo $this->getPagerHtml() ?>

</div>

And then the function

  protected function _getAvailableLimit($mode)
        {
            if (isset($this->_availableLimit[$mode])) {
                return $this->_availableLimit[$mode];
            }
            $perPageConfigKey = 'catalog/frontend/' . $mode . '_per_page_values';
            $perPageValues = (string)Mage::getStoreConfig($perPageConfigKey);
            $perPageValues = explode(',', $perPageValues);
            $perPageValues = array_combine($perPageValues, $perPageValues);
            if (Mage::getStoreConfigFlag('catalog/frontend/list_allow_all')) {
                return ($perPageValues + array('all'=>$this->__('All')));
            } else {
                return $perPageValues;
            }
        }

Best Answer

I have the same issue and spend many hours trying to solve it. My dev now made a core 'hack' - for those interested;

app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php (line 227)

    /* FIX: SHOW ALL ITEMS */
    if($this->getLimit() == 'all'){
      $limit = 1000000;
    } else {
      $limit = (int)$this->getLimit();
    }

Beware it's a CORE hack, you will lose the 'fix' when upgrading. And it's more a bandage then a fix. But if anyone else have a better solution then please share it.

Related Topic