5

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;
            }
        }
23
  • have you tried to do reindex?
    – ivantedja
    Aug 14, 2015 at 13:47
  • No could this be an indexing issue?
    – Klettseb
    Aug 14, 2015 at 13:53
  • 2
    check the SQL query. After $_productCollection->count(); do echo $_productCollection->getSelect()->__toString() and check if you see something wrong. Sep 4, 2015 at 13:13
  • 2
    Which GET request do you mean?
    – Klettseb
    Sep 4, 2015 at 14:02
  • 1
    @Thomas I think this is custom functionality so tracing how it has been developed should give you have answer. Sep 7, 2015 at 9:47

2 Answers 2

2

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.

1
  • 2
    You know you can override this by adding your code to the local/Mage rather than hack the core. Oct 29, 2015 at 13:01
0

Might be worth checking your php settings as loading that many products at one time will be a drain on memory.

I wouldn't necessarily look for things like php memory limits and max load times - but where these are set i would advise a look as it could be getting to outputting 3 but due to other settings it is causing it to fail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.