Saturday 15 February 2014

Show all sub categories with thumbnail

create file in location: aa/desing/frontend/ theme/catelog/category/subcat.phtml
<?php
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
        ->addAttributeToSelect(array('name', 'thumbnail'))
        ->addAttributeToFilter('is_active', 1)
        ->addIdFilter($category->getChildren())
?>
<ul class="subcategories">
    <?php foreach ($categories as $category): ?>
        <li>
            <a href="<?php echo $category->getUrl() ?>"><img src="<?php echo Mage::getBaseUrl('media')?>catalog/category/<?php echo $category->getThumbnail() ?>" height="150" width="150" alt="<?php echo $this->htmlEscape($category->getName()) ?>" />
                <span><?php echo $category->getName() ?></span></a>
        </li>
    <?php endforeach; ?>
</ul>

how to call in:
{{block type="core/template" template="catalog/category/subcat.phtml"}}

create static block and past code: {{block type="core/template" template="catalog/category/subcat.phtml"}}

Now go to admin, select particualr category and click to display setting tab and select Display Mode "  static block only "  and select CMS Block...

ENJOY :)

No comments:

Post a Comment