Magento 1.7 All Categories and respective Thumbnails -
i need list categories , respective thumbnails. problem can't display thumbnails. have tried tutorials , nothing. here list of posts explaning different approaches nether 1 works: list of examples cant make them work
this current code:
<?php $_helper = mage::helper('catalog/category') ?> <?php $_categories = $_helper->getstorecategories() ?> <?php if (count($_categories) > 0): ?> <ul> <?php foreach($_categories $_category): ?> <li> <a href="<?php echo $_helper->getcategoryurl($_category) ?>"> <?php echo $_category->getname() ?> </a> <?php $_category = mage::getmodel('catalog/category')->load($_category->getid()) ?> <?php $_subcategories = $_category->getchildrencategories() ?> <?php if (count($_subcategories) > 0): ?> <ul> <?php foreach($_subcategories $_subcategory): ?> <li> <a href="<?php echo $_helper->getcategoryurl($_subcategory) ?>"> <?php echo $_subcategory->getname() ?> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> </ul> <?php endif; ?>
got it. here result, need attribute collection , image respective folder:
<?php $_helper = mage::helper('catalog/category'); ?> <?php $_categories = $_helper->getstorecategories(false, true, false) //here solution ->addattributetoselect('thumbnail') ->addorderfield('name'); ?> <?php if (count($_categories) > 0): ?> <ul> <?php foreach($_categories $_category): ?> <li> <a href="<?php echo $_helper->getcategoryurl($_category) ?>"> <?php echo $_category->getname(); echo '<img src="'.mage::getbaseurl('media').'catalog/category/'.$_category->getthumbnail().'" width="100" height="100"/>'; ?> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?>
Comments
Post a Comment