如何在Magento APi上创建子类别

时间:2011-04-27 07:04:43

标签: soap magento soap4r

我目前正在使用Magento ver。 1.5.0.1。谁能告诉我如何使用soapv2创建一个子类别。

这是我的代码格式

category_data = { "name" => "LIGHTING", "is_active" => 1 }
soap.call('catalogCategoryCreate',session,4,category_data,1, "include_in_menu")

运行此代码时出现了一些错误。

: Attribute "include_in_menu" is required. (SOAP::FaultError)

这是解决这个问题的方法吗。

感谢。

2 个答案:

答案 0 :(得分:0)

category_data = { "name" => "LIGHTING", "is_active" => 1, "include_in_menu" => 1 }

答案 1 :(得分:0)

这是使用SOAP V2创建类别的方法

<?php
    $host = "192.168.0.10/~aliasgar/magentoext/index.php"; //our online shop url
    $client = new SoapClient("http://".$host."/api/v2_soap/?wsdl"); //soap handle
    $apiuser= "aliasgar"; //webservice user login
    $apikey = "aliasgar"; //webservice user pass
    try { 

    $sess_id= $client->login($apiuser, $apikey); //we do login

    $result = $client->catalogCategoryCreate($sess_id, 3, array(
        'name' => 'Test Category',
        'is_active' => 1,
        'available_sort_by' => array('position'),
         'default_sort_by' => 'position',
        'include_in_menu' => '1',
    ));

    var_dump ($result);
    }
    catch (Exception $e) { //while an error has occured
        echo "==> Error: ".$e->getMessage(); //we print this
           exit();
    }

&GT;

这里的catalogCategoryCreate函数中的3是父类别id。