samedi 18 avril 2015

How to display magento product categories in column wise

I'm trying to display all the categories below the main title, so I want to display four categories in each column. The below is my code



<?php
$_category = $this->getCurrentCategory();
$collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
$helper = Mage::helper('catalog/category');
?>
<ul class="pull-left">
<?php foreach ($collection as $cat):?>
<li>
<a style="color:#fff;" href="<?php echo $helper->getCategoryUrl($cat);?>">
<cite><?php echo $cat->getName();?><?php
?></cite>
</a>
</li>
<?php endforeach;?>
</ul>


HTML Output



<ul class="pull-left">
<li>....</li>
<li>....</li>
<li>....</li>
<li>....</li>
<li>....</li>
<li>....</li>
<li>....</li>
<li>....</li>
.
.
.
.
</ul>


I want to define four li items in every ul. Like this



<ul class="pull-left">
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
<ul class="pull-left">
<li>...</li>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>


I also want to display product count and I've tried this



<?php
$products_count = Mage::getModel('catalog/category')->load($categoryId)->getProductCount();
?>


but it is not working.


Aucun commentaire:

Enregistrer un commentaire