Add multiple products to a category

PatrickManPatrickMan Member Posts: 6

I want to add multiple products to one category. I'm aware of the existing CategoriesProducts API which makes it possible to add a single product to multiple categories. But I want to do the opposite, I want to add multiple products to one category. Is this possible?

7 comments

  • Ali_MasoumieAli_Masoumie Moderator, Lightspeed Staff Posts: 147 moderator

    Hi,

    You can write a script to do this. Basically you would need to have the product_ID's and a script to run the same piece of code for every product.

  • PatrickManPatrickMan Member Posts: 6

    Hey,

    What if I want to update 2000 products which are in 10 different categories. Would you advice me to do 2000 API calls?

    Or is there a way to do 10 API calls with the product ids in the request? (this is what I prefer)

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 881 moderator

    Hi @PatrickMan,

    Updating products is bases on productID https://developers.lightspeedhq.com/ecom/endpoints/product/#put-update-a-product.

    When your script loops over these products keep in mind about the rate limits as well. The default limits are 300 calls per 5 min. So you'll have to built in a sleep to avoid hitting these limits. Your developer should know this.

    I hope this helps.

  • PatrickManPatrickMan Member Posts: 6

    Hi @LucienVersendaal ,

    I am a developer and I know how the API works. But I think that the current API works very inefficient when it comes to adding products to a category.

    Instead of doing 200 API calls to sort 200 products in a category, I want to do it in a single API call. For example a bulk insert which allows you to insert multiple products into a single category.


    Besides the bulk insert, a PUT method on the categoriesProduct endpoint to update the SortOrder would also help.


    I hope you can help me with this.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 881 moderator

    @PatrickMan,

    Unfortunately, there is no other way to do it at this moment.

    The categoryProduct endpoint is only managing the relationship between categories and products.

    I will make a feature request for adding multiple products into a category.

  • PatrickManPatrickMan Member Posts: 6
    edited April 19

    Thank you! @LucienVersendaal

    Can I track the status of this feature request? We're really depending on it.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 881 moderator

    @PatrickMan

    I've sent you the ticket.

Sign In or Register to comment.