My store running on Magento 1.942.

I want to display subcategories on a category page, and find this guide https://www.magemonkeys.com/how-to-display-sub-categories-on-a-category-page-in-magento/.

I create a Static Blocks and subcategory_listing.phtml according to the guide, everything works fine.

but when I enable cache in "Cache Storage Management", All parent categories on my store display the same subcategories (For example, after refreshing the Magento cache, if I click on the A parent category and then click on the other parent category, the subcategories under the A parent category are displayed.).

I refreshed the Magento cache, the browser cache, but nothing changed.

here are the codes of subcategory_listing.phtml

$layer = Mage::getSingleton('catalog/layer');
$_category  = $layer->getCurrentCategory();
$_categories = $_category->getCollection()->addAttributeToSelect(array('url_key','name','image','all_children','is_anchor','description'))
->addAttributeToFilter('is_active', 1)
->setOrder('position', 'ASC')
<div class="listing-type-list catalog-listing">
<ul id="subcats" class="clear">
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<?php Mage::log($_category->debug(), null, 'mylogfile.log'); ?>
<div class="category-box clearfix">
<a class="now-from-container" href="<?php echo $_category->getURL() ?>"></a>
<div class="category-image-box">
<a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>">
<img src="<?php echo $this->htmlEscape($_category->getImageUrl()) ?>" width="135" alt="<?php echo $this->htmlEscape($_category->getName()) ?>" />
<div class="category-name">
<h2><a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a></h2>
<?php endif; ?>
<?php endforeach; ?>
<div style="clear:both;"> </div>

  • Does anyone reply to me?
    – Clark
    Commented Oct 8, 2019 at 23:41

1 Answer 1


I am looking for a solution as well on
Looks like an issue similar to what happened in 1.9.2 documented in the link below.
Blocks HTML Cache & Sub Category Display

I've tried these two modules and neither did the trick.

Edit: Here is what I ended up doing:

Previously I was trying to add the block as a static block calling the phtml file. On this link I got the idea to turn off the cache on the block via xml. https://www.creare.co.uk/blog/magento/magento-subcategories-category-pages

I ended up using the following method to get subcategories to display correctly and not duplicate for each category: <action method="setCacheLifetime"><s>null</s></action>
Which I believe prevents the subcategory block from being cached and duplicating.

My subcategory block was located at ...catalog/navigation/sub_category_listing.phtml

I added my sub categories block to my catalog.xml with:
<block type="catalog/navigation" name="sub_category_listing" before="category.products" template="catalog/navigation/sub_category_listing.phtml"> <action method="setCacheLifetime"><s>null</s></action> </block>

And positioned the block with the following in the view.phtml file:

<?php echo $this->getLayout()->createBlock('catalog/navigation')->setTemplate('catalog/navigation/sub_category_listing.phtml')->toHtml(); ?>

I am not going to show the code I used for the subcategory block since I don't know where I got it and there are probably much better examples now (was from an old site I am upgrading). Hope this helps!

  • I use your method, and it is working fine on my website, thank you very much!
    – Clark
    Commented Oct 10, 2019 at 1:37
  • Glad I could help! Thanks
    – danbacci
    Commented Oct 10, 2019 at 5:44
  • Clark, can you accept my answer if it worked? Thanks!
    – danbacci
    Commented Oct 13, 2019 at 21:44

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.