GraphQL API can query Order.LineItems.SellingPlan.SellingPlanId
I can use query node(id:“sellingPlanIdHere”) and obtain the selling plan from the sellingPlanId.
However, I also need to get the group for the selling plan. The selling plan does not have a sellingPlanGroupId property and neither does the line item . Is there a way to obtain the selling plan group from the selling plan without hunting through all the product’s selling plans? (would be too inefficient and likely exceed throttle)
Hello @appdev2023 !
We currently do not return the sellingPlanGroupId as part of the sellingPlan, but I will pass along this feedback to the team!
One other option, is that we can expose the sellingPlanGroups that are linked to the Product:
https://shopify.dev/docs/api/storefront/unstable/connections/SellingPlanGroupConnection
However, I realize that is also not the best solution as a single product can have multiple selling plan groups, each with multiple selling plans.
This actually will be immediately rejected by shopify throttle. hunt through unknown # products * unknown # groups * unknown # plans… it is just too much (ex: first10productsfirst10groupsfirst10plans is already 1000)
Any one of the following would resolve this:
- add a LineItemSellingPlanGroup as a property of LineItem
- add sellingPlanGroupId as a property of LineItemSellingPlan
- add sellingPlan & sellingPlanGroup as connections on LineItem. (this is better than the one-off LineItemSellingPlan type)
- add sellingPlanGroup as a connection on SellingPlan
Of course, #4 is preferable because the benefit isn’t limited to line items.