2

In template/page/html/pager.phtml there is the following line which defines whether to show the item count on the product list toolbar:

<?php if($this->getShowAmounts()): ?>

Where is getShowAmounts() set in the backend?

2 Answers 2

2

In the construct of Mage_Page_Block_Html_Pager showAmounts is set to true using $this->setData('show_amounts', true);.

However since on the category page's pager.phtml is usually called using getPagerHtml() from within toolbar.phtml and toolbar.phtml by default has it's own amounts html it doesn't really make sense to display it twice so within the getPagerHtml method of Mage_Catalog_Block_Product_List_Toolbar showAmounts is set to false here

$pagerBlock->
...
 ->setShowAmounts(false)
...

That said if you do need to set it back to true you can observe core_block_abstract_to_html_before and do something like below.

    <?php class Namespace_Name_Model_Observer
{
    public function coreBlockAbstractToHtmlBefore(Varien_Event_Observer $observer){
        $block = $observer->getEvent()->getBlock();
        $blockNameInLayout = $block->getNameInLayout();

        switch ($blockNameInLayout) {
            case 'product_list_toolbar_pager' :

                $block->setShowAmounts(true);
                break;
        }

    }
}
0

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

Interesting part:

public function getPagerHtml()
    {
        $pagerBlock = $this->getChild('product_list_toolbar_pager');

        if ($pagerBlock instanceof Varien_Object) {

            /* @var $pagerBlock Mage_Page_Block_Html_Pager */
            $pagerBlock->setAvailableLimit($this->getAvailableLimit());

            $pagerBlock->setUseContainer(false)
                ->setShowPerPage(false)
                ->setShowAmounts(false)
                ->setLimitVarName($this->getLimitVarName())
                ->setPageVarName($this->getPageVarName())
                ->setLimit($this->getLimit())
                ->setFrameLength(Mage::getStoreConfig('design/pagination/pagination_frame'))
                ->setJump(Mage::getStoreConfig('design/pagination/pagination_frame_skip'))
                ->setCollection($this->getCollection());

            return $pagerBlock->toHtml();
        }

        return '';
    }

Interesting line: ->setShowAmounts(false)

if you want to change it to true you have to override the block with your own module.

1
  • I haven't checked for alternatives. But in this case, you can use an observer which sets the property to true in core_block_abstract_to_html_before Oct 12, 2014 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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