2013-12-12 19 views

回答

0

是你可以箱子自己的API与使用下面category.list链接,您可以确保创建API

Create new magento Rest api to get category list in magento

此外,如果你想创建自己的函数来获取类别你也可以创建你自己的功能如下

function get_categories(){ 

$category = Mage::getModel('catalog/category'); 
$tree = $category->getTreeModel(); 
$tree->load(); 
$ids = $tree->getCollection()->getAllIds(); 
$arr = array(); 
if ($ids){ 
foreach ($ids as $id){ 
$cat = Mage::getModel('catalog/category'); 
$cat->load($id); 
$arr[$id] = $cat->getName(); 
} 
} 

return $arr; 

} 


    $arr = get_categories(); 
$arr = array_flip($arr); 
echo "<pre>"; 
var_dump($arr); 
echo "</pre>"; 

希望这一定能帮助你。

+0

希望我的回答对你有用。如果是>,请不要忘记接受 – liyakat

相关问题