Hi all,
I need to display a list of say 20 products. If any of those have variants I also have to display the proper name and prices for that item. Currently what I have is very slow when you receive 20 items that belong to an item group. You have to run 20 extra queries to fetch those item groups and all of its properties (N+1 problem).
Is that a more effective way to display a list of 20 products with all their info. Currently I have something like this:
collection = get("/merchants/#{mid}/items")
collection.each {
get("/merchants/#{mid}/item_groups/#{item_group_id}") if has_item_group?
}
I've tried to use expand
with itemGroup but the api seems to just ignore it and the api explorer also doesn't offer the itemGroup option. I've also tried to grab a collection of item group ids so I could fetch them all in one query but it doesn't seem to be possible either via api. Apparently filter
only work with AND
not OR
.
I wonder how clover devices use the api for displaying a list of 10 full products for example (regular items and item with variants)? Is there any way to avoid those N+1? thanks appreciate it