How to get shopify’s product variant title, images, and price in PHP using API?

Step 1 Create a new php file. here we create product_price.php and paste the below code in it.
<?php
require_once("inc/functions.php");

$requests = $_GET;
$hmac = $_GET['hmac'];
$serializeArray = serialize($requests);
$requests = array_diff_key($requests, array('hmac' => ''));
ksort($requests);

$token = 'PASTE YOUR TOKEN HERE'
$shop = 'PASTE YOUR SHOP URL HERE'
Step 2 Now define variables for set data.
$image = '';

$title = '';

$id = '';

$originalPrice = '';

$discountedPrice = '';
Step 3 Now use the below api.
$collectionList = $shopify->shopify_call($access_token, $shop, "/admin/api/2022-01/custom_collections.json", array(), 'GET');

$collectionList = json_decode($collectionList['response'], JSON_PRETTY_PRINT);

$collection_id = $collectionList['custom_collections'][1]['id'];



$array = array("collection_id"=>$collection_id);

$collects = $shopify->shopify_call($access_token, $shop, "/admin/api/2022-01/collects.json", $array, 'GET');

$collects = json_decode($collects['response'], JSON_PRETTY_PRINT);

?>
Step 4 Now create a table to view our data and use the for loop for get data one by one to set it in table.
<table class="table table-striped table-hover">

                                        <thead>

                                        <tr>

                                                <th colspan="4"> Store products</th>

                                        </tr>

                                        <tr><th><input class="chk_u"  type="checkbox" id="select-all-u">

    <label for ="select-all-u">Select All</label></th></tr>

                                        </thead>



                                        <tbody>

<?php

foreach($collects as $collect){ 

   $i=1; foreach($collect as $key => $value){ 

    	

        $products = $shopify->shopify_call($access_token, $shop, "/admin/api/2022-01/products/".$value['product_id'].".json", array(), 'GET');

		$products = json_decode($products['response'], JSON_PRETTY_PRINT);

		

        $images = $shopify->shopify_call($access_token, $shop, "/admin/api/2022-01/products/".$value['product_id']."/images.json", array(), 'GET');

        $images = json_decode($images['response'], JSON_PRETTY_PRINT);


        $variants = $shopify->shopify_call($access_token, $shop, "/admin/api/2020-10/products/".$value['product_id']."/variants.json", array(), 'GET');
		$variants = json_decode($variants['response'], JSON_PRETTY_PRINT);
		
		

        

        // echo $products['product']['title'].'<br>';

               

                $image = $images['images'][0]['src'];

                 $title = $products['product']['title'];

                  $id = $products['product']['id'];

                $originalPrice = $variants['variants'][0]['compare_at_price'];

		        $discountedPrice = $variants['variants'][0]['price'];
                  

            ?>

        <tr>

                                                <td><a href="#"><?php echo $i; ?></a></td>

                                                <td><a href="#"  target="_blank"><input class="chk_u" value="<?php echo $id; ?>" type="checkbox"  name="product_id[]"/></a></td>

                                                <td><a href="#"><img  src=" <?php echo $image ?> " alt="product images" style="width: 40px; "></a></td>

                                                <td><a href="#"><h6><?php echo $title ?></h6></a></td>

                                                <td><a href="#"><h6><?php echo $id ?></h6></a></td>
                                                <td><a href="#"><h6><?php echo $originalPrice ?></h6></a></td>
                                                <td><a href="#"><h6><?php echo $discountedPrice ?></h6></a></td>

                                        </tr>

                                        <?php           

         $i++;       }

        } ?>

 </tbody>



                                </table>