$base='Host';
$proxy = new SoapClient($base.'/api/v2_soap?wsdl=1');
$sessionId = $proxy->login('user123', 'user123'))
$allCategories = $proxy -> catalogCategoryTree($sessionId, 2);
$allCategories = get_object_vars($allCategories);
$i = 0;
foreach($allCategories['children'] as $k => $v ){
$v=get_object_vars($v);
$cat[$i]["RootCategory"] = array("Category" => $v['name']);
$subCat = $proxy -> catalogCategoryTree($sessionId, $v['category_id']);
$subCat = get_object_vars($subCat);
$ii = 0;
foreach($subCat['children'] as $k1=>$v1) {
$v1 = get_object_vars($v1);
$cat[$i]["SubCategory"][$ii]['Subcatinfo']= array("SubCategory" =>$v1['name'],"SubCategory_id"=>$v1['category_id']);
$res = $proxy->catalogCategoryAssignedProducts($sessionId,$v1['category_id']);
$iii = 0;
foreach($res as $key=>$value) {
$value = get_object_vars($value);
$att=array("name", "description", "short_description");
$res2 = $proxy -> catalogProductInfo($sessionId,'13');
foreach($res2 as $key2=>$value2) {
var_dump("Name=>",$value2['name']);
$value2 = get_object_vars($value2);
$cat[$i]["SubCategory"][$ii]['Product_Details'][$iii]["Product_info"]= array("Product_id"=>$value['product_id'],"Product_Name" =>$value2["name"],"Product_sku"=>$value2["sku"],"Product_Categories"=>$value2['categories']);
}
$iii++;
}
$ii++;
}
$i++;
}
echo json_encode($cat);
and the OutPut of the Following Code is given below-
[
{
"RootCategory": {
"Category": "Mens Wear"
}
},
{
"RootCategory": {
"Category": "Womens Wear"
}
},
{
"RootCategory": {
"Category": "Mobile Phones"
}
},
{
"RootCategory": {
"Category": "Grocery"
},
"SubCategory": [
{
"Subcatinfo": {
"SubCategory": "SPICES & SEASONING",
"SubCategory_id": 28
}
},
{
"Subcatinfo": {
"SubCategory": "CEREALS & PULSES",
"SubCategory_id": 29
}
},
{
"Subcatinfo": {
"SubCategory": "RICE & FLOUR",
"SubCategory_id": 30
},
"Product_Details": [
{
"Product_info": {
"Product_id": 13,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
},
{
"Product_info": {
"Product_id": 24,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
}
]
},
{
"Subcatinfo": {
"SubCategory": "OIL & GHEE",
"SubCategory_id": 31
}
},
{
"Subcatinfo": {
"SubCategory": "SWEETNER & WHITNER",
"SubCategory_id": 32
}
},
{
"Subcatinfo": {
"SubCategory": "OTHERS",
"SubCategory_id": 33
}
}
]
},
{
"RootCategory": {
"Category": "Food"
},
"SubCategory": [
{
"Subcatinfo": {
"SubCategory": "DRIED READY MEALS",
"SubCategory_id": 34
}
},
{
"Subcatinfo": {
"SubCategory": "SAUCES,SPREADS & PICKLES",
"SubCategory_id": 35
}
},
{
"Subcatinfo": {
"SubCategory": "BAKERY",
"SubCategory_id": 36
}
},
{
"Subcatinfo": {
"SubCategory": "CHIPS & NAMKEENS",
"SubCategory_id": 37
}
}
]
},
{
"RootCategory": {
"Category": "BEVERAGES"
},
"SubCategory": [
{
"Subcatinfo": {
"SubCategory": "TEA & COFFEE",
"SubCategory_id": 42
}
},
{
"Subcatinfo": {
"SubCategory": "HEALTH & ENERGY DRINKS",
"SubCategory_id": 43
}
},
{
"Subcatinfo": {
"SubCategory": "FRUIT DRINKS",
"SubCategory_id": 44
}
}
]
},
{
"RootCategory": {
"Category": "PERSONAL CARE"
},
"SubCategory": [
{
"Subcatinfo": {
"SubCategory": "FACE CARE & LOTION",
"SubCategory_id": 41
}
},
{
"Subcatinfo": {
"SubCategory": "FACE WASH & SCRUBS",
"SubCategory_id": 45
}
},
{
"Subcatinfo": {
"SubCategory": "SHAMPOO & CONDITIONER",
"SubCategory_id": 46
},
"Product_Details": [
{
"Product_info": {
"Product_id": 17,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
}
]
},
{
"Subcatinfo": {
"SubCategory": "ORAL CARE",
"SubCategory_id": 47
}
},
{
"Subcatinfo": {
"SubCategory": "BODY & HANDWASH",
"SubCategory_id": 48
}
},
{
"Subcatinfo": {
"SubCategory": "HAIR OIL & SERUM",
"SubCategory_id": 49
},
"Product_Details": [
{
"Product_info": {
"Product_id": 16,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
},
{
"Product_info": {
"Product_id": 21,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
}
]
},
{
"Subcatinfo": {
"SubCategory": "DEO,PERFUMES & TALC",
"SubCategory_id": 50
}
},
{
"Subcatinfo": {
"SubCategory": "HAIR STYLING CREAMS & GEL",
"SubCategory_id": 51
}
},
{
"Subcatinfo": {
"SubCategory": "SHAVING NEEDS",
"SubCategory_id": 52
}
},
{
"Subcatinfo": {
"SubCategory": "SHOE CARE",
"SubCategory_id": 58
}
}
]
},
{
"RootCategory": {
"Category": "DETERGENT & TOILETRIES"
},
"SubCategory": [
{
"Subcatinfo": {
"SubCategory": "DETERGENT BAR & POWDER",
"SubCategory_id": 53
},
"Product_Details": [
{
"Product_info": {
"Product_id": 14,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
},
{
"Product_info": {
"Product_id": 15,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
},
{
"Product_info": {
"Product_id": 20,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
},
{
"Product_info": {
"Product_id": 22,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
}
]
},
{
"Subcatinfo": {
"SubCategory": "SANITARY&FLOOR CLEANERS",
"SubCategory_id": 54
}
},
{
"Subcatinfo": {
"SubCategory": "FABRIC CARE",
"SubCategory_id": 55
}
},
{
"Subcatinfo": {
"SubCategory": "DETERGENT BAR & POWDER",
"SubCategory_id": 56
}
},
{
"Subcatinfo": {
"SubCategory": "DISHWASHER AGENTS",
"SubCategory_id": 57
}
}
]
},
{
"RootCategory": {
"Category": "Baby CARE"
},
"SubCategory": [
{
"Subcatinfo": {
"SubCategory": "BABY DIAPERS",
"SubCategory_id": 59
}
},
{
"Subcatinfo": {
"SubCategory": "BABY CREAMS",
"SubCategory_id": 60
},
"Product_Details": [
{
"Product_info": {
"Product_id": 18,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
}
]
},
{
"Subcatinfo": {
"SubCategory": "BABY SOAP",
"SubCategory_id": 61
}
},
{
"Subcatinfo": {
"SubCategory": "BABY SHAMPOO",
"SubCategory_id": 62
}
},
{
"Subcatinfo": {
"SubCategory": "BABY OIL",
"SubCategory_id": 63
}
},
{
"Subcatinfo": {
"SubCategory": "BABY FOOD",
"SubCategory_id": 64
}
}
]
},
{
"RootCategory": {
"Category": "OTHER PRODUCTS"
},
"SubCategory": [
{
"Subcatinfo": {
"SubCategory": "REPELLENT",
"SubCategory_id": 73
}
},
{
"Subcatinfo": {
"SubCategory": "MEDICATIONS&TREATMENT",
"SubCategory_id": 74
},
"Product_Details": [
{
"Product_info": {
"Product_id": 23,
"Product_Name": null,
"Product_sku": null,
"Product_Categories": null
}
}
]
},
{
"Subcatinfo": {
"SubCategory": "WOMEN'S HYGIENE",
"SubCategory_id": 75
}
},
{
"Subcatinfo": {
"SubCategory": "CONDOMS",
"SubCategory_id": 76
}
},
{
"Subcatinfo": {
"SubCategory": "SEXUAL WELLNESS",
"SubCategory_id": 77
}
},
{
"Subcatinfo": {
"SubCategory": "FOIL PAPER & NAPKINS",
"SubCategory_id": 78
}
}
]
}
]
Why i am getting null values for product details.Tried everything but can't get those exact values. If i passed a string (product_id) explicitly,i got correct output like
Input- $res = $proxy -> catalogProductInfo($sessionId,'13');
$res = $proxy -> catalogProductInfo($sessionId,'13');
$res = get_object_vars($res);
echojson_encode(array("Product_Name"=>$res['name'],"Product_sku"=>$res['sku'],"Product_Categories"=>$res['categories']));
Output-
{"Product_Name":"AASHIRVAAD SELECT ATTA","Product_sku":"A00669","Product_Categories":["2","18","30"]}
Thanks