How to create sub category on Magento APi

1.3k Views Asked by At

I am currently using Magento ver. 1.5.0.1. Can anyone tell me how do i create a sub category using soapv2.

Here my code format

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

I got some errors when i run this code.

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

Is that any solution for this problem.

Thanks.

2

There are 2 best solutions below

0
On BEST ANSWER
category_data = { "name" => "LIGHTING", "is_active" => 1, "include_in_menu" => 1 }
0
On

This is how you can create category using 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();
    }

?>

Here 3 in the catalogCategoryCreate function is the parent category id.