I am trying to return a set of product in magento 2 rest web api from the product repository. All working fine. But when I trying to return the result, the result is not in the form of a associative array. Following is the var_dump of the array before the return.
array(1) {
["product_categories"]=>
array(3) {
["sale_items"]=>
array(1) {
[0]=>
string(28) "array of items in sale items"
}
["featured_items"]=>
array(1) {
[0]=>
string(32) "array of items in featured_items"
}
["new_style_items"]=>
array(1) {
[0]=>
string(36) "array of items new_style_items items"
}
}
}
I am expecting the following result.
[
"product_categories": {
"sale_items": [
"array of items in sale items"
],
"featured_items": [
"array of items in featured_items"
],
"new_style_items": [
"array of items new_style_items items"
]
}
]
But I am receiving the following result.
[
{
"sale_items": [
"array of items in sale items"
],
"featured_items": [
"array of items in featured_items"
],
"new_style_items": [
"array of items new_style_items items"
]
}
]
My php code is
$homePageProducts['product_categories'] = array ('sale_items' => array('array of items in sale items'),
'featured_items' => array('array of items in featured_items'),
'new_style_items' => array('array of items new_style_items items'));
return $homePageProducts;
My return type is "mixed[]"