2

I want to display the total number of currently found/selected above/inside the layered navigation. In the templates catalog/layer/view.phtml or catalog/layer/state.phtml

I tried:

/* @var Mage_Catalog_Model_Category $_category */
$_category = Mage::registry('current_category');
var_dump($_category->getProductCount());

And a few other functions that are in the class but none seem to give the number I need. Anyone who can help me out?

1 Answer 1

2

Try to get

$select = clone Mage::getSingleton('catalog/layer')->getProductCollection()->getSelect();

Then you can modify the $select object to get COUNT() and fetch it.

Note, you have the right collection with all filters applied after the render of catalog/layer/view block.

You need to use clone, as later magento will use the same collection for pager and product list.

2
  • 1
    I found Mage::getSingleton('catalog/layer')->getProductCollection()->getSize() which returns a int of the products. Do I still need to clone? It doesn't look like it affects anything.
    – janw
    Commented Jul 25, 2014 at 12:09
  • If it works fine and does not affects the product listing it's OK.
    – Amasty
    Commented Jul 25, 2014 at 13:02

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.