In magento file system, editing the category pages can be accomplish by navigating to the category phtml file. It's file directory is somewhat like this:
“app/design/frontend/packagename/themeanme/template/catalog/category/view.phtml”
NOTE: Please take note to replace you’re the packagename and themename that you are using.
To display the category image for both parent and children category you can try the following code on the phtml I’ve mentioned above.
The above code will loop on each current category and display the image corresponds to it.
“app/design/frontend/packagename/themeanme/template/catalog/category/view.phtml”
NOTE: Please take note to replace you’re the packagename and themename that you are using.
To display the category image for both parent and children category you can try the following code on the phtml I’ve mentioned above.
<?php $_category = $this->getCurrentCategory(); $collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id); //Get the current category and its children foreach ($collection as $category){ //Loop through the categories $subCategory = Mage::getModel('catalog/category')->load($category->getId());
//Get the child category models $imgSrc = $subCategory->getImageUrl(); //Get the image url if($imgSrc){ echo '<img src="'.$imgSrc.'" />'; //Echo the image } } ?>
The above code will loop on each current category and display the image corresponds to it.
2 comments:
This works great for mw
great solution, well done!
Post a Comment