How can I add a collection to an array?
I have a variable named “product_availability_all_sites” which is an empty array. Using an iterator, I want to loop through and add new array elements (collections) that looks like the following structure:
{
"site": "main",
"stockLevel": 23
}
After all the iterations, the goal is for the “product_availability_all_sites” array to look like:
[
{ "site": "main", "stockLevel": 23 },
{ "site": "US", "stockLevel": 12 },
{ "site": "DE", "stockLevel": 43 }
]
However, with my current approach, I always get the error:
“Failed to map ‘value’: Function ‘add’ finished with error! Function ‘toArray’ finished with error! ‘{“site”:“main”,“stockLevel”:23}’ is not a valid collection.”
Thank you for your help.