Category Product remove doesn't work anymore

SjoerdRuttenSjoerdRutten Member Posts: 7
edited January 18 in Development

Since today I can't remove CategoryProduct via the API anymore, adding works but removal doesn't. I still got the response code 204 with no content as expected. Can anybody help ?

Post edited by SjoerdRutten on

9 comments

  • Ali_MasoumieAli_Masoumie Lightspeed Staff Posts: 28 Lightspeed

    Hi @SjoerdRutten,

    I was not able to reproduce the issue you are having.

    Can you send the request you are making and the response you get so we can have a closer look.

  • SjoerdRuttenSjoerdRutten Member Posts: 7

    Hi Ali,

    after investigating further I found the problem is slightly different. When I get the product via the API I get a resource for categoryProduct:

    array:1 [

     "resource" => array:3 [

      "id" => false

      "url" => "categories/products?product=117527711"

        "link" => "https://api.webshopapp.com/nl/categories/products.json?product=117527711"

     ]

    ]

    when I get the 'categories - products' via the link given in de resource I get all the products, nog only the categories for the given product. So to find the categories for a specific product I have to retrieve all the records (in my case about 20750 records) to find the categories for this specific product. In the worst case scenario I have to make 83 API calls to find the right categoriesProduct id.

    I may be wrong but this used to be different.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 662 moderator

    Hi @SjoerdRutten,

    The link that is provided https://api.webshopapp.com/nl/categories/products.json?product=117527711" is giving you all the categories attached to the product. That is what you need right according to"So to find the categories for a specific product"?

  • SjoerdRuttenSjoerdRutten Member Posts: 7
    edited January 21

    Yes, it gives me all the categories attached to the product with all products attached to that categories! Product 117527711 is attached to 5 categories, but I get 20750 records back because I get every product attached to these 5 categories.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 662 moderator

    What do you mean with "with all products attached to that categories! "?

    Product 117527711 is attached to 5 categories, but I get 20750 records back because I get every product attached to these 5 categories. What call are you making?

  • SjoerdRuttenSjoerdRutten Member Posts: 7

    I make the call https://api.webshopapp.com/nl/categories/products.json?product=117527711 I expect to only get records for product 117527711 but I get a record for every product attached to the categories of product 117527711.

    As example the first records of the response from the API call mentioned. As you can see all the products are different from the queried product

    {

     "categoriesProducts": [

      {

       "id": 833561411,

       "sortOrder": 975,

       "category": {

        "resource": {

         "id": 3231464,

         "url": "categories\/3231464",

         "link": "https:\/\/api.webshopapp.com\/nl\/categories\/3231464.json"

        }

       },

       "product": {

        "resource": {

         "id": 117629189,

         "url": "products\/117629189",

         "link": "https:\/\/api.webshopapp.com\/nl\/products\/117629189.json"

        }

       }

      },

      {

       "id": 833561410,

       "sortOrder": 4350,

       "category": {

        "resource": {

         "id": 2495502,

         "url": "categories\/2495502",

         "link": "https:\/\/api.webshopapp.com\/nl\/categories\/2495502.json"

        }

       },

       "product": {

        "resource": {

         "id": 117629189,

         "url": "products\/117629189",

         "link": "https:\/\/api.webshopapp.com\/nl\/products\/117629189.json"

        }

       }

      },

      {

       "id": 833556018,

       "sortOrder": 976,

       "category": {

        "resource": {

         "id": 3231464,

         "url": "categories\/3231464",

         "link": "https:\/\/api.webshopapp.com\/nl\/categories\/3231464.json"

        }

       },

       "product": {

        "resource": {

         "id": 117628686,

         "url": "products\/117628686",

         "link": "https:\/\/api.webshopapp.com\/nl\/products\/117628686.json"

        }

       }

      },

      {

       "id": 833556017,

       "sortOrder": 4357,

       "category": {

        "resource": {

         "id": 2495502,

         "url": "categories\/2495502",

         "link": "https:\/\/api.webshopapp.com\/nl\/categories\/2495502.json"

        }

       },

       "product": {

        "resource": {

         "id": 117628686,

         "url": "products\/117628686",

         "link": "https:\/\/api.webshopapp.com\/nl\/products\/117628686.json"

        }

       }

      },

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 662 moderator

    Your shopID is 95054, right?

    That's really weird, I tested it and was getting just the categories attached to the product, here's my response.

    {
        "categoriesProducts": [
            {
                "id": 833120406,
                "sortOrder": 237,
                "category": {
                    "resource": {
                        "id": 10364294,
                        "url": "categories/10364294",
                        "link": "https://api.webshopapp.com/nl/categories/10364294.json"
                    }
                },
                "product": {
                    "resource": {
                        "id": 117527711,
                        "url": "products/117527711",
                        "link": "https://api.webshopapp.com/nl/products/117527711.json"
                    }
                }
            },
            {
                "id": 833120405,
                "sortOrder": 683,
                "category": {
                    "resource": {
                        "id": 10364293,
                        "url": "categories/10364293",
                        "link": "https://api.webshopapp.com/nl/categories/10364293.json"
                    }
                },
                "product": {
                    "resource": {
                        "id": 117527711,
                        "url": "products/117527711",
                        "link": "https://api.webshopapp.com/nl/products/117527711.json"
                    }
                }
            },
            {
                "id": 833120404,
                "sortOrder": 1987,
                "category": {
                    "resource": {
                        "id": 3231462,
                        "url": "categories/3231462",
                        "link": "https://api.webshopapp.com/nl/categories/3231462.json"
                    }
                },
                "product": {
                    "resource": {
                        "id": 117527711,
                        "url": "products/117527711",
                        "link": "https://api.webshopapp.com/nl/products/117527711.json"
                    }
                }
            },
            {
                "id": 833120403,
                "sortOrder": 4347,
                "category": {
                    "resource": {
                        "id": 2495502,
                        "url": "categories/2495502",
                        "link": "https://api.webshopapp.com/nl/categories/2495502.json"
                    }
                },
                "product": {
                    "resource": {
                        "id": 117527711,
                        "url": "products/117527711",
                        "link": "https://api.webshopapp.com/nl/products/117527711.json"
                    }
                }
            }
        ]
    }
    


  • SjoerdRuttenSjoerdRutten Member Posts: 7

    I think I got it. In Laravel I can't directly call the url with the querystring. I have to seperate the querystring. Thank you!

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 662 moderator

    Okay perfect!

Sign In or Register to comment.