cancel
Showing results for 
Search instead for 
Did you mean: 

How to Fix: Show Sub-Category on Category page

How to Fix: Show Sub-Category on Category page

I'm having issues with my coding, I'm trying to show my categories sub-categories thumbnails on the categories page.

The problem is that it's showing the same sub-category on different categories instead of just showing the sub-category from that parent category.

 

CMS Block: {{block type="core/template" template="subcategories.phtml" }}

 

.PHTML File:

 

<div class="clearfix title-container product-slider-container"></div>
<?php
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
->addAttributeToSelect(array('name', 'thumbnail'))
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
?>
<?php foreach ($categories as $category): ?>
<a href="<?php echo $category->getUrl() ?>"><img src="<?php echo Mage::getBaseUrl('media') . 'catalog' . DS . 'category' . DS . $category->getThumbnail() ?>"/></a>
<?php endforeach; ?>

 

Magento ver. 1.9.2.4

1 REPLY

Re: How to Fix: Show Sub-Category on Category page

You could try using getChildrenCategories

 

$children = $category->getChildrenCategories();

Regards
Sven