<?php

 

    print "<table border='1' width='50%' align='center'>";

	print "<tr>
				<td>Sr No</td>
				<td>Product Name</td>
				<td>Category</td>
				<td>Title</title>
				<td>Product ID</td>
				<td>Variant ID</td>
				<td>Product Price</td>
				<td>Product PV</td>
			</tr>";


	 $apiUrl = "https://1713a997b65da8e11f975a8af6b39a3b:31625375addd3a85d103fccaa7bb6680@marvel-mii.myshopify.com/admin/products.json";

	 $data = curlRequest($apiUrl);

	 function curlRequest($url){

			$url = $url;
			//$params = $data;
			//print_r($data_string);
			$session = curl_init($url);
		    //curl_setopt($session, CURLOPT_HEADER, true);
			curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($session, CURLOPT_HTTPHEADER, array('X-HTTP-Method-Override: POST'));
			curl_setopt($session, CURLOPT_CUSTOMREQUEST, 'GET');
			curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
			curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
			$result = curl_exec($session);
			$response = json_decode($result);
			curl_close($session);
			//echo '<pre>';
			//var_dump($response);
			return $response;
			
	   
		}

	$count=1;
	foreach($data->products as $row)
	{

		foreach($row->variants as $row2)
		{

			echo "<tr>";
			echo "<td>". $count      ."</td>";
			echo "<td>". $row->title ."</td>";
			echo "<td>". $row->product_type   ."</td>";
			echo "<td>". $row2->title ."</td>";
			echo "<td>". $row2->product_id    ."</td>";
			echo "<td>". $row2->id    ."</td>";
			echo "<td>". $row2->price    ."</td>";
			echo "<td></td>";
			echo "</tr>";
			$count=$count+1;
		}
		

	}

?>