Magento Asked by Sanya Zahid on January 30, 2021
I have used this code in view.phtml to display subcategories on category page
<?php foreach ($this->getCurrentCategory()->getChildrenCategories() as $_subcat): ?>
<li><a href="<?php echo $_subcat->getUrl() ?>"><?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName(), 'name') ?></a></li>
<?php endforeach ?>
but this is obviously displaying only the list of subcategories, I want image and same view as products on category page
Desired Result
Getting this
Favorite community please help 🙂
Use below code
$_category = Mage::registry('current_category');
$subcategories = Mage::getModel('catalog/category')->getCategories($_category->getId());
foreach ($subcategories as $subcategory){ ?>
<li><a href="<?php echo $subcategory->getUrl() ?>"><?php echo $subcategory->getName() ?></a></li>
<?php }
Answered by Akhil Gupta on January 30, 2021
Try to make a var dump of "$_subcat" inside the foreach:
<?php foreach ($this->getCurrentCategory()->getChildrenCategories() as $_subcat): ?>
<?php var_dump($_subcat->getData()); die(); ?>
<?php endforeach ?>
You will display all the options available to use.
Answered by Andrea Rivadossi on January 30, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP