0

I am attempting to display all sub-categories of a parent category on a static block page (e.g. brands will show all sub-categories such as Adidas, Nike etc.). I am having problems at the moment calling the category image. It is the category image I am looking for and not the thumbnail.

Here's my code:

                    <?php 
                    //If there are sub categories
                    $categories = $this->getCurrentChildCategories();
                    $categoriescount = $this->getCurrentChildCategories()->count();
                    if ($categoriescount > 0): 
                    ?>
                    <div class="sub-category-container">    
                        <?php 
                        //Loop through categories
                        foreach ($categories as $category):
                        ?>
                        <div class="sub-category">
                            <a href="<?php echo $this->getCategoryUrl($category)?>" class="cat-image">
                            <?php 
                            // If there is a thumbnail set for the category - Display it
                            if($imgUrl = Mage::getModel('catalog/category')->load($category->getId())->getThumbnail()):?>
                            <img src="<?php echo $this->getBaseUrl()."media/catalog/category/".$imgUrl ?>" width="220" height="110" alt="<?php echo $this->htmlEscape($category->getName()) ?>" />
                            <?php endif; ?>
                            </a>
                            <div class="inner-sub-category">
                                <a href="<?php echo $this->getCategoryUrl($category)?>" class="sub-link"><?php echo $category->getName()?></a>
                                <a href="<?php echo $this->getCategoryUrl($category)?>" class="btn"><span>View All</span></a>
                            </div>
                        </div>

                        <?php endforeach; ?>
                    </div>
                    <?php else:?>
                    <p>No Sub Categories</p>
                    <?php endif; ?>
1

1 Answer 1

0

It was as simple as changing this line from 'Thumbnail' to 'Image':

 if($imgUrl = Mage::getModel('catalog/category')->load($category->getId())->getImage()):?>

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.