I am looking to query all of products within my store, and handle the results based on the “collections” attribute, which are things like [“fruit-based”,“cream-based”], etc. When I query the “Stores/Products” Collection using the command below,
// Query all products
wixData.query("Stores/Products").find().then((results) => {// handle the results});
The response doesn’t give me the “collections” attribute for each item. Here is an example of a single item (i.e. banana), which should have an “collections” attribute of [“cream-based”]:
{
"inStock": true,
"weight": 0,
"name": "Banana",
"sku": "",
"formattedDiscountedPrice": "$50.00",
"productOptions": {
"Drizzle": {
"optionType": "drop_down",
"name": "Drizzle",
"choices": [
{
"inStock": true,
"visible": true,
"mainMedia": null,
"description": "Drizzle",
"mediaItems": [],
"value": "Drizzle"
},
{
"inStock": true,
"visible": true,
"mainMedia": null,
"description": "Plain",
"mediaItems": [],
"value": "Plain"
}
]
}
},
"mainMedia": "wix:image://v1/44508c_848b9f8638a94c44a1543d70b58eb799~mv2.jpg/file.jpg#originWidth=1600&originHeight=1067",
"description": "",
"_id": "9188169b-6029-05e5-1b0d-5eec19bcd793",
"discountedPrice": 50,
"formattedPrice": "$50.00",
"price": 50,
"inventoryItem": "6e77e964-9fd6-fa1a-e4f2-a113e643286c",
"_updatedDate": "2023-03-23T21:10:39.427Z",
"slug": "banana",
"productType": "physical",
"ribbons": [],
"mediaItems": [
{
"description": "",
"id": "44508c_848b9f8638a94c44a1543d70b58eb799~mv2.jpg",
"src": "wix:image://v1/44508c_848b9f8638a94c44a1543d70b58eb799~mv2.jpg/file.jpg#originWidth=1600&originHeight=1067",
"title": "Rotated.jpg",
"type": "Image"
}
],
"trackInventory": false,
"customTextFields": [],
"ribbon": "",
"currency": "USD",
"productPageUrl": "/product-page/banana",
"manageVariants": false,
"discount": {
"type": "NONE",
"value": 0
},
"additionalInfoSections": [],
"createdDate": "2023-03-13T11:00:29.866Z"
}
As you can see, there are no collections field. However, when I look at the Stores/Products" Collection using content manager, it’s there.
How can I get the “collections” field from the Stores/Products" Collection using the Velo API?
Thanks!