Load relations for a specific category

SystemSystem Posts: 2
This discussion was created from comments split from: Need help on displaying all products in one category.

11 comments

  • thisisbolothisisbolo Posts: 25Member
    Hi Leah, I would think it’s from 1 category. I’m trying to figure out how to change the url parameter and combine other specifics to show product out of 1 category. Is this possible?
    Super Cat Lightspeed
  • thisisbolothisisbolo Posts: 25Member
    I.e. if I wanted to do the following but to do for a specific category in my lightspeed inventory 

    ?load_relations=["ItemShops", "ItemVendorNums"]&ItemShops.qoh=>,0
    Super Cat Lightspeed
  • thisisbolothisisbolo Posts: 25Member
    @Leah Forgot to @ you
    Super Cat Lightspeed
  • JoeyJoey moderator Posts: 186Administrator, Moderator, Lightspeed Staff moderator
    The original question is posted in the Theme Design & Customizations category for Lightspeed eCom. It looks like your question is related to the Retail API, if this is the case I recommend posting in the correct Retail API category.
    eCom Support Team
    Lightspeed HQ
  • thisisbolothisisbolo Posts: 25Member
    Sorry, I didn’t originally post this. Anyone the forum moderators can move this thread?
    Super Cat Lightspeed
  • Adrian SamuelAdrian Samuel moderator Posts: 545Moderator, Lightspeed Staff moderator
    Hey @thisisbolo, thank you for your question, you'll want to make a request like this:

    https://api.lightspeed.com/API/Account/{{AcccountId}}/Item.json?load_relations=["Category"]&categoryID={{number}}

    Now since you'll have to specify the number and not the name, you want to make an initial request to the Category endpoint to get that data. More information about this can be found here:

    https://developers.lightspeedhq.com/retail/endpoints/Category/

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • thisisbolothisisbolo Posts: 25Member
    Thanks Adrian. It worked!
    Super Cat Lightspeed
  • thisisbolothisisbolo Posts: 25Member
    @Adrian Samuel

    Calling the parent category doesn’t pull the items that are in sub categories of that parent. Is there a way to make this happen?
    Super Cat Lightspeed
  • gregaricangregarican  Posts: 311Member 
    edited October 2018
    I'm not sure if you can accumulate the top parent ID and all of its descendant ID's and issue that as a blanket query. Something like this:

    https://api.merchantos.com/API/Account/{AccountId}/Item.json?load_relations=["Category"]&categoryID=1,2,3,4,5&limit=100

    I tried playing around with this, and couldn't find a way to pass the proper query parameter. If I tried just two categoryID's like &categoryID=1,2 then only the second category ID would appear in the response. If I tried any more than two ID's then I got a query parameter error response. And bracket notation doesn't seem to work for passing multiple values in there.

    If that all is the case, unless I'm missing something, I think you would have to derive the categoryID list all the top-level parent and all of its children. And pass the item query for each individual categoryID. Definitely not very efficient is you're talking about a deeper hierarchy and a lot of items.
  • thisisbolothisisbolo Posts: 25Member
    Yes, that's long and not efficient. There has to be a way. I can't see this being built to not support this type of query. Hopefully someone on here knows the answer. @Adrian Samuel ;)
    Super Cat Lightspeed
  • gregaricangregarican  Posts: 311Member 
    I've kept repeating my strategy, so take it with a grain of salt if it doesn't apply or otherwise make sense. If you don't need near real-time data, I'd suggest just pulling the various recordsets via the API as part of a scheduled daily job. Push them into a local SQL-based DB table set. Then you can query things however you'd like.

    As long as the enduser or the application can live with previous day's data as being most current, then the responsiveness is great. And you can link the different tables together however you'd like for better flexibility. Due to slice-and-dice requirements that might change at a later time.

    Of course if you are looking at implementing a more real-time integrated app or reporting tool set that's all a moot point.  
Sign In or Register to comment.