2

a question what can be useful to know is how to use code from other pages into the current page you are working on?

e.g. I want to echo the total product count of the search query on list.phtml

Currently the product count is used in the pager/toolbar.phtml:

<?php echo $this->__('%s Item(s)', $this->getTotalNum()) ?>

Now when i try this in list.phtml it's not working. How can i get that to work?

2

Take a look on app\design\frontend\base\default\layout\catalog.xml

<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">

is a child block of

<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">

So, if you want to call getTotalNum() which is the method of catalog/product_list_toolbar block. You just need to get its child block product_list_toolbar and call the method.

$this->getChild('product_list_toolbar')->getTotalNum();

From other point of view, if you just need to get amount of products in list.phtml you can get it in this way:

$_productCollection->count()

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.