我在下面的代码中获得子类别描述时遇到了问题。
$category_model = Mage::getModel('catalog/category');
$_category = $category_model->load(3); //loaded one category
$_subcategories = $_category->getChildrenCategories();
foreach($_subcategories as $_subcategory):
echo $_subcategory->getName();
echo $_subcategory->getDescription(); //I can't able to get description of the subcategory
endforeach;
答案 0 :(得分:1)
得到了解决方案,我添加了回答我的问题。很多优化的答案也将受到赞赏。感谢。
$category_model = Mage::getModel('catalog/category');
$_category = $category_model->load(3); //loaded one category
$_subcategories = $_category->getChildrenCategories();
foreach($_subcategories as $_subcategory):
echo $_subcategory->getName();
//echo $_subcategory->getDescription(); //I can't able to get description of the subcategory
//Added to make as current category
$cur_category=Mage::getModel('catalog/category')->load($_subcategory->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
echo $this->getCurrentCategory()->getDescription();
endforeach;
答案 1 :(得分:0)
我不是100%肯定你想做什么,但试试
$category_model = Mage::getModel('catalog/category');
$_category = $category_model->load(3); //loaded one category
$_subcategories = $_category->getChildrenCategories();
foreach($_subcategories as $_subcategory):
$cur_category=Mage::getModel('catalog/category')->load($_subcategory->getId());
echo $cur_category->getName();
echo $cur_category->getDescription();
endforeach;