I am using magento 1.7. I create a category "A" and in it i create others categories. I created a static block and affect to the category "A". I wish to display the categories name and his count in all categories using static block. Can i do that with static block or with other solution ?


You sure can - first, create a custom block:

YourCompany_YourModule_Block_Category extends Mage_Core_Block_Abstract
    protected function _toHtml()
        $category = Mage::registry('current_category');
        $name = $category->getName();
        $numProducts = $category->getCollection()->getSize();

        $html = parent::_toHtml();
        return $html .= "$name, number of products: $numProducts";


Then you add it to your static block:

{{block type='yourblock/category' name='your.custom.name'}}

If all goes well, you should see at the top of your category something like "Televisions, number of products: 42".

Best of luck!

| improve this answer | |
  • I must create a new module ? – Amirov Sep 13 '13 at 7: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.