Php 如何根据magento中的父类别id及其子类别获取类别
我想根据特定的父类别id和它们的子类别获取子类别,我尝试了下面的脚本Php 如何根据magento中的父类别id及其子类别获取类别,php,magento,Php,Magento,我想根据特定的父类别id和它们的子类别获取子类别,我尝试了下面的脚本 $children = Mage::getModel('catalog/category')->getCategories(1234); foreach ($children as $category) { $parent_cat[] = $category->getName();
$children = Mage::getModel('catalog/category')->getCategories(1234);
foreach ($children as $category) {
$parent_cat[] = $category->getName();
}
echo '<pre>';
var_dump($parent_cat);
exit();
$children=Mage::getModel('catalog/category')->getCategories(1234);
foreach($children作为$category){
$parent_cat[]=$category->getName();
}
回声';
$cat = Mage::getModel('catalog/category')->getCategories(140);
//$subcats = $cat->getChildren();
foreach ($cat as $category) {
$parent_cat[] = $category->getName();
$cat_id = $category->getChildren();
foreach ($cat_id as $sub_category_id){
$sub_cat[] = $sub_category_id->getName();
}
}
变量转储($parent\u cat);
退出();
通过上面的脚本,我根据父Id获得了所有子类别,但我还需要从父Id获得的所有子类别的子类别。有人能帮我吗?最后,我自己找到了解决方案:-)