Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Get only latest product data from api without product id in php

Solved

Get only latest product data from api without product id in php

Mohd_Shariq
Shopify Partner
3 0 0

Hey dear,


I need latest product data from a Shopify store with the help of API 

 

Example: I have a [ABC]  product in the store, but when I add new product like { dummy  } in store, then I need to get only { dummy } product data from the API without product id 

 

I'm using PHP curl functions 

<?php

$new_product = shopify_call($token,$shop_url, "/admin/api/2021-10/products.json", array(), 'GET');
$new_product_str = json_decode($new_product['response'], JSON_PRETTY_PRINT); ?>

 

 

Thanks and regard

Mohd. Shariq

Accepted Solution (1)

m8th
Shopify Partner
13 5 11

This is an accepted solution.

Hi

 

Use limit = 1 and created_at_max = (current datetime) to get the newest product only

/admin/api/2021-10/products.json?limit=1&created_at_max=2022-08-25T07:48:59+00:00

 

You can generate the timestamp in the desired format with the following command:

date(DATE_ATOM, time());

 

Ref

RTFM!

View solution in original post

Reply 1 (1)

m8th
Shopify Partner
13 5 11

This is an accepted solution.

Hi

 

Use limit = 1 and created_at_max = (current datetime) to get the newest product only

/admin/api/2021-10/products.json?limit=1&created_at_max=2022-08-25T07:48:59+00:00

 

You can generate the timestamp in the desired format with the following command:

date(DATE_ATOM, time());

 

Ref

RTFM!