The workaround was to call
inventoryConnector.getItemWithCategories(itemId)
instead of
inventoryConnector.getItem(itemId)
otherwise the categories array is not getting populated at all.
Do not trust the accepted answer.
public java.util.List<Category> getCategories()Categories associated with this item
Hi @Jonathan Ryan Grice, unfortunately I can't find your answer useful as of now.
I am calling getCategories() on the Item instance fetched via either the OrderConnector or InventoryConnector but the list is empty.
For instance, using Kotlin:
val item = inventoryConnector.getItem("my item id") item.categories // empty
Is there any way to tell the SDK to also fetch the categories, like in a GraphQL fashion?
To give you a better understanding here's an example of an item I have in the inventory.
Item: Large Beer
Categories: Drinks, ...
Tags: Alcohol, ...
I can read all the item properties (e.g. the tags) but not the categories.
It's worth noting that the categories array is null and hasCategories always returns false, while on items with no tags I always get a non null list (empty or with some tags) and hasTags always returns true. Sounds like a serialization/deserialization issue on the SDK itself?
Thanks for your help.
It's a function, meaning it will call getCagegories() on the Java code. Added my answer with the real solution. Thank you anyway!
2 People are following this question.