5

I have tried modifying getLimit() in the file Mage_Catalog_Block_Product_List_Toolbar, but that didn't seem to change anything. Is this even possible?

5

This may not achieve what you want but it's worth mentioning: you can disable the 'memorization' of product list toolbar parameters by calling the following method:

Mage_Catalog_Block_Product_List_Toolbar::disableParamsMemorizing()

Or, via layout XML you can update the toolbar block of your category handle as follows:

<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
    <action method="disableParamsMemorizing"></action>
    <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>

Notice I've added the <action> node with a call to the disableParamsMemorizing method.

This will prevent the user's toolbar params from being stored in their session and will reset it each time they load the page, provided it doesn't have the param in a query string. Keep in mind this will 'forget' ALL toolbar params:

  1. sort_order
  2. sort_direction
  3. display_mode
  4. limit_page

You could also apply this on a per-category basis via layout updates in the Magento Admin.

1

It seems as if you rewrote the method as follows it would do what you want it to do:

public function getLimit()
{
    $limit = $this->_getData('_current_limit');
    if ($limit) {
        return $limit;
    }
    $limit = $this->getRequest()->getParam($this->getLimitVarName(), $this->getDefaultPerPageValue());

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

What I've done here is remove the conditions that set/get the limit values from the catalog session. This means that if the limit is set in the querystring it will obey it but it will not store it in the session, so it's only applying the limit for those who change the products-per-page dropdown value - not for their return visits where they likely hit a category page by browsing the site or by organic search.

If the limit value was not set in the querystring it then defaults to the value set in the configuration.

Best of luck!

  • I modified the code, but it didn't change anything. I even hard coded a return number, but even that didn't do anything. I made sure to clear my cache first. – swl1020 Feb 20 '14 at 17:58

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.