2015-09-24 187 views

回答

0

嗯,我得到了子類的方式如下:

<?php 
if (Mage::registry('current_product')) { 
    if ($_product) { 
     $categoryIds = $_product->getCategoryIds();    
     $cat_id = $categoryIds[0]; ----> pass the level of sub catgeory to the array index 
     $category = Mage::getModel('catalog/category')->load($cat_id); 
     $cat_name = $category->getName(); 
    } 
} 
?> 
0

得到一個類別的子類別,使用下面的代碼

$your_category_id = '2334'; // category_id whose subcategory you want to fetch 
$subcats = Mage::getModel('catalog/category')->getCategories($your_category_id); 
foreach ($subcats as $sub) { 
    echo $sub->getName(); 
} 
+0

我需要選擇的子類,不是所有的類別的類別。 –

相關問題