php - Magento Fetching image through childcategory -
i have following code set display subcategories of category. (to achieve categories category).
however dont seem able fetch images throuhg childcategories, can me ?
my code looks following.
<?php $_helper = mage::helper('catalog/category') ?> <?php $categoryid = 465;?> <?php $category = mage::getmodel('catalog/category')->load($categoryid) ?> <?php $_categories = $category->getchildrencategories() ?> <?php if (count($_categories) > 0): ?> <ul> <?php foreach($_categories $_category): ?> <li> <?php $_category = mage::getmodel('catalog/category')->load($_category->getid()) ?> <?php if($_category->haschildren()):?> <?php $_subcategories = $_category->getchildrencategories() ?> <ul class="catblocks"> <?php foreach($_subcategories $_subcategory): ?> <li class="item<?php if(($i-1)%$_columncount==0): ?> first<?php elseif($i%$_columncount==0): ?> last<?php endif; ?>"> <a href="<?php echo $_helper->getcategoryurl($_subcategory) ?>"><?php echo $_subcategory->getname() ?></a> <a href="<?php echo $_helper->getcategoryurl($_subcategory) ?>"><img src="<?php echo $_subcategory->getimageurl() ?>" alt="<?php echo $_subcategory->getname() ?>" /> <span><?php echo $_subcategory->getname() ?></span></a> <?php $_category2 = mage::getmodel('catalog/category')->load($_subcategory->getid()) ?> <?php if($_category2->haschildren()):?> <?php $_subcategories2 = $_category2->getchildrencategories() ?> <?php endif; ?> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> </ul>
wiki
Comments
Post a Comment