2

I'm currently developing a website for a client, which seems to have created a problem for itself... Or I have, but I can't figure out where or how?!

Basically, using the quick search, it will display all the results on the same page.... Even if there are 3,000 results!

The pagination is set up correctly, for both grid & list. The toolbar displays the amount of pages there should be, yet still displays all results on the single page.

Layered navigation is set up and showing.

I'm not sure if I'm allowed to display URL's on here, but if I am an example search is here: http://dev.cblsupplies.co.uk/catalogsearch/result/index/?cat=63&q=light

As you can, it's having a negative impact on performance due to the vast amount of results!

I'm really stumped on this one, I've searched and searched for a resolution - but I'm unable to find one. If anyone could point me in the right direction I'd be eternally grateful.

  • A modification made by the theme might be the issue. Can you check if it created a module folder and if so, what is the module doing? – mbalparda Aug 7 '14 at 15:39
  • Where exactly would I be searching for this module folder? It was working fine, when I checked it about a week ago. I've been working on a different section of the site and came back to the search results today. That is when I noticed the issue. – user3652959 Aug 7 '14 at 16:00
  • app/code/[local,community] – mbalparda Aug 7 '14 at 16:20
1

Most probably the toolbar block does not add limit to the sql query. For example because some other block load the collection before the toolbar.

Search for $collection->getSize();

Or similar method calls. At the background they may init sql query that returns not paginated results

  • Ok, so I can't see any reference to getSize(); - I disabled the current theme, and tested it with another. It works perfectly. So it's definitely something to do with the theme! Now time to dig a bit deeper. – user3652959 Aug 7 '14 at 18:06
  • Glad to hear the answer helps ) – Amasty Aug 7 '14 at 19:02
1

Take a look on catalog.xml file in the location app/design/frontend/base/default/layout/catalog.xml. The handles that you need to study are catalog_category_default and catalog_category_layered. The following code snippet is taken from catalog_category_default. The same portion is also awailable for the handle catalog_category_layered.

<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
    <block type="page/html_pager" name="product_list_toolbar_pager"/>
        <!-- The following code shows how to set your own pager increments -->
        <!--
            <action method="setDefaultListPerPage"><limit>4</limit></action>
            <action method="setDefaultGridPerPage"><limit>9</limit></action>
            <action method="addPagerLimit"><mode>list</mode><limit>2</limit></action>
            <action method="addPagerLimit"><mode>list</mode><limit>4</limit></action>
            <action method="addPagerLimit"><mode>list</mode><limit>6</limit></action>
            <action method="addPagerLimit"><mode>list</mode><limit>8</limit></action>
            <action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
        -->
    </block>
    ...
</block>

This is what our default toolbar block definition. Now look on those actions that are commented out inside toolbar block. The method that we interested here is addPageLimit. This method is used to set page limit for toolbar block. In order to test it, you need to edit your theme's catalog.xml file. In that file, if this section exists, just add this codes there

<action method="addPagerLimit"><mode>list</mode><limit>9</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>9</limit></action>

Samething you need to do for the handle catalog_category_layered. Then clear cache and try again.

You can also take a look on my blog which teaches how can we set page size via observer. You can get that extension through github.

Note: Make sure cache is cleared before refresh the page.

Hope it helps for you.

  • thanks for your comment. I've given that a shot, but unfortunately it's made no difference to the result output. I can't understand what's made it mess up like this. It was working perfectly last week. I've disabled all new modules that have been implemented since then, but still nothing. It's really puzzling me! – user3652959 Aug 7 '14 at 19:52
  • did you try my extension ? – Rajeev K Tomy Aug 8 '14 at 3:44

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.