question

Dan avatar image
Dan asked Dan commented

Is it possible to get items for a category via the database?

I need to get all of the items for a particular category, with tags expanded.

/categories/" + categoryID + "/items?expand=tags"

This works fine for me using a web request but for some reason it is failing for live merchants and I can't tell why yet. I load up categories via the inventory connector, the merchant chooses one and then I load up the inventory for it (with tags expanded via the above request). The categories load is fine so if I can do the same thing via the inventory connector or directly in SQL I think my problems will go away.

Thanks, Dan

Inventory
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Dan avatar image
Dan answered Dan commented

I don't see any way to use an InventoryConnector to get items with tags in bulk for a given category, but you should be able to use InventoryConnector#getTagsForItem(String itemId).

          List<Category> categories = inventoryConnector.getCategories();
          for (Category category : categories) {
            if (category.isNotEmptyItems()) {
              for (Reference itemRef : category.getItems()) {
                List<Tag> tags = inventoryConnector.getTagsForItem(itemRef.getId());
                for (Tag tag : tags) {
                  Log.d("TagTest", tag.toString());
                }
              }
            }
          }

I'd be mindful of/test the performance with large categories and many tags.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dan avatar image Dan commented ·

Thanks Dan, I think this will do what I need

0 Likes 0 ·

Welcome to the
Clover Developer Community