How to view Sub Categories only in Parent Categories from Magento?

<?php
$obj = new Mage_Catalog_Block_Navigation();
$current_cat     = $obj->getCurrentCategory();

$currentCatId    = (is_object($current_cat) ? $current_cat->getId() : ”);

$currentPage = (int) $this->getRequest()->getParam(‘p’, 1);
//$currentPage = $_GET[‘p’];

$pageSize = 3;

$collection = Mage::getModel(‘catalog/category’)->getCollection()
->addAttributeToFilter(‘parent_id’, $currentCatId)
->addAttributeToSelect(‘name’)
->addAttributeToSelect(‘url’)
->setLoadProductCount(1)
->setOrder(‘name’, ‘asc’)
->setPage($currentPage, $pageSize);

$totCat = $collection->getSize();
$store_cats = $collection->load();

$pageTot = ceil( $totCat / $pageSize );

?>
<div>
<ul class=’navigation’>
<?php foreach ($store_cats as $cat) : ?>
<li><a href=”<? echo $cat->getUrl() ?>”><?php echo $cat->getName() . ” (” . $cat->getProductCount() . “)” ?></a>
<?php echo $cat->getImageUrl(); ?>
</li>
<?php endforeach; ?>
</ul>

</div>

<ul>
<?php for ( $i=1; $i<=$pageTot; $i++ ) : ?>
<?php if ( $i == $currentPage ) : ?><li><?php echo $i ?></li><?php else : ?><li><a href=”<?php echo $current_cat->getUrl() ?>?p=<?php echo $i ?>”><?php echo $i ?></a></li><?php endif; ?>
<?php endfor; ?>
</ul>

And Just Put below code in your CMS (or) Static Block page inside.
{{block type=”catalog/navigation” name=”catalog.categories” alias=”all_categories_homepage” template=”catalog/navigation/category_listing.phtml”}}

How to Show Magento Particular Categorie Image in Magento?

<?php
$cat_id = 8; // set desired category id
$category = Mage::getModel('catalog/category')->load($cat_id);
$products = $category->getProductCollection()->
addCategoryFilter($category)->addAttributeToSelect('*');
?>
<?php foreach ( $products as $_product ): ?>
<a href="<?php echo $_product->getProductUrl() ?>">
<img src="<?php echo $this->helper('catalog/image')->
init($_product, 'small_image')->resize(135, 135); ?>"
width="135" height="135" title="<?php echo $_product->getName() ?>"
alt="<?php echo $_product->getName() ?>" /></a>
<?php endforeach; ?>

How to view All Categories only in Home from Magento?

<?php $_maincategorylisting=$this->getCurrentCategory()?>
<?php $_categories=$this->getCurrentChildCategories()?>
<!– h2><?php //echo $this->__(‘Browse Products’) ?> </h2 –>
<div>
<ul>
<? foreach ($_categories as $_category):?>
<? if($_category->getIsActive()): ?>
<?php $cur_category=Mage::getModel(‘catalog/category’)->load($_category->getId()); ?>
<?php $layer = Mage::getSingleton(‘catalog/layer’); ?>
<?php $layer->setCurrentCategory($cur_category);
//$this->getCurrentCategory()->getImageUrl()
?>
<? if($_imageUrl=$this->getCurrentCategory()->getThumbnailUrl()):?>
<li> <a href=”<?php echo $this->getCategoryUrl($_category) ?>” title=”<?php echo $this->htmlEscape($_category->getName()) ?>”>
<img src=”<?php echo $_imageUrl ?>” width=”auto” alt=”<?php echo $this->htmlEscape($_category->getName()) ?>” />
</a>
<a href=”<?php echo $this->getCategoryUrl($_category) ?>” title=”<?php echo $this->htmlEscape($_category->getName()) ?>”>
<?php echo $this->htmlEscape($_category->getName()) ?>
</a>
<? if($_description=$this->getCurrentCategory()->getDescription()):?>
<p>
<?php echo $_description ?></p></li>
<?php endif; ?>
<? endif; ?>
<? endif; ?>
<?php endforeach; ?>
<div></div>
</ul>
<div></div>
</div>
<?php $layer->setCurrentCategory($_maincategorylisting); ?>

Just Put your home page or Any Static Page this below Line only :

{{block type=”catalog/navigation” name=”catalog.categories” alias=”all_categories_homepage” template=”catalog/navigation/all_category_view.phtml”}}

Welcome to our other site : www.srinesiga.com

© 2020 Spirituality