开发者

Magento categories display in front end question

开发者 https://www.devze.com 2023-02-05 17:32 出处:网络
+Parent cat1 +Parent cat2 +Parent cat3 +subc开发者_StackOverflowat1 -subcat11 -subcat12 subcat2 subcat3 +Parent cat4
+Parent cat1
+Parent cat2
+Parent cat3
   +subc开发者_StackOverflowat1
      -subcat11
      -subcat12
   subcat2  
   subcat3
+Parent cat4

My requirement is when you click the parent cat3 how can I display the subcat1 and subact2?

When I click the subcat11 I cannot display the subcat2, subcat3.

What I require is when I click the subcat11 or subcat12 it should show like this below

  subcat1
      -subcat11
      -subcat12
   subcat2  
   subcat3

Can you help me with this?

My code is given below.

$loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
$subCategories = explode(',', $loadCategory->getChildren()); 

foreach ( $subCategories as $subCategoryId )
{   
    $cat = Mage::getModel('catalog/category')->load($subCategoryId);

    if ($cat->getIsActive())
    {         
        if ($currentCat->getEntityId() == $subCategoryId)
        {
            echo '<li ><a href="'.$cat->getURL().'">'.$cat->getName().'</a></li>'; 
        } 
    }
} 


The vertical navigation extension has a flexible option to choose which categories will appear as 'root'. Perhaps you can use this instead of writing it yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消