Get all product attributes via API not returning all attributes sometimes

GroeierGroeier Member Posts: 3
edited May 19 in Development

Hi,

I read this API documentation (https://developers.lightspeedhq.com/ecom/endpoints/productattribute/#get-all-product-attributes) and wrote a script for it to get all the product attributes for each product. But sometimes it does not return all the product attributes. For example if I make the call. It gives me 5 product attributes while the product has 6 attributes in that case. But sometimes a product has 9 attributes and it returns 9 attributes so sometimes it returns all the attributes and sometimes some attributes are missing. Someone has had this problem too?

I am getting the attributes via my php script beneath. product_id 26469894 has 6 attributes but it returns only 5 attributes.

<?php

  //$product_ids = [26469894,119349985,113177925];

  $product_ids = [26469894];

  foreach($product_ids as $product_id) {

        $url = 'https://KEY:[email protected]/en/products/'.$product_id.'/attributes.json';

    // Takes raw data from the request

    $json = file_get_contents($url);

    // Converts it into a PHP object

    $data = json_decode($json);

    echo '<pre>';

    print_r($data);

    echo '</pre>';

  }

?>

Tags:
Sign In or Register to comment.