skip to Main Content

There is an Shopify API limit of 250 products so in order to get all product data I need to combine all pages into one PHP variable. So far I have the following but it doesn’t work. Should I be defining $test as an array?

PHP is not my strong point so I’ve probobaly got the syntax all wrong. I just need to be able to read the data provided by both URL’s defined as $productspageone and $productspagetwo

$test = array();
$productspageone = json_decode(httpGet($apiUrl . "/admin/products.json?limit=250&page=1"));
$productspagetwo = json_decode(httpGet($apiUrl . "/admin/products.json?limit=250&page=2"));

$test = json_decode(productspageone);
$test = json_decode($test=json_decode(productspagetwo);

2

Answers


  1. Try this
    it will decode responsed to arrays, then u have to merge them, u will have everything in the variable now

    $productspageone = json_decode(httpGet($apiUrl . "/admin/products.json?limit=250&page=1"),true);
    $productspagetwo = json_decode(httpGet($apiUrl . "/admin/products.json?limit=250&page=2"),true);
    
    $test = array_merge($productspageone,$productspagetwo);
    
    Login or Signup to reply.
  2. Yuo can make an array of all that items

    $test = [ $productspageone, $productspagetwo ];
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search