【问题标题】:How to create Categories webservice api in magento and in android app如何在 magento 和 android 应用程序中创建类别 webservice api
【发布时间】:2013-12-30 17:08:09
【问题描述】:

我想知道如何在 magento 1.8.0 中创建 Web 服务,它获取商店的所有类别名称,然后我需要在我的 Android 应用程序上显示。

所以请指教。

【问题讨论】:

    标签: web-services magento magento-1.8


    【解决方案1】:

    是的,您可以使用以下链接为 category.list 创建自己的 api,您一定可以创建自己的 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>";
    

    希望这对你有帮助。

    【讨论】:

    • 希望我的回答对你有用。如果是,请不要忘记接受>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多