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.

/admin/api/2023-10/products.json?fields=variants but want to get only active items

Solved

/admin/api/2023-10/products.json?fields=variants but want to get only active items

DutchDelight
Excursionist
30 0 6

Hi there,

 

We use /admin/api/2023-10/products.json?fields=variants to get item info, however, that info does not show if an item is archived or active. Is there a way to get those filtered and if so how?

Accepted Solution (1)

Cherb20
Shopify Partner
6 2 4

This is an accepted solution.

Hi DutchDelight,

 

You can retrieve additional fields by adding them to the fields sections. So if you need to retrieve a product's status as well as its variants you can do something like this:

 

/admin/api/2023-10/products.json?fields=variants,status

 

 That should return all the variants and the status of each product.

 

If you need to only return the products with a certain status you can add an additional parameter shown below.

 

Lets say you want to only retrieve "active" products, you would add "&status=active" like so:

 

/admin/api/2023-10/products.json?fields=variants,status&status=active

 

This will return all variants and the status of all products that are active. You can change the "active" to whatever you need.

 

Hope this helps.

If I answered your question, please Accept my answer as the solution 🙂
If you found any information I've provided helpful, please give a Thumbs Up

If you have any questions, feel free to reach out or message me.

View solution in original post

Replies 3 (3)

Cherb20
Shopify Partner
6 2 4

This is an accepted solution.

Hi DutchDelight,

 

You can retrieve additional fields by adding them to the fields sections. So if you need to retrieve a product's status as well as its variants you can do something like this:

 

/admin/api/2023-10/products.json?fields=variants,status

 

 That should return all the variants and the status of each product.

 

If you need to only return the products with a certain status you can add an additional parameter shown below.

 

Lets say you want to only retrieve "active" products, you would add "&status=active" like so:

 

/admin/api/2023-10/products.json?fields=variants,status&status=active

 

This will return all variants and the status of all products that are active. You can change the "active" to whatever you need.

 

Hope this helps.

If I answered your question, please Accept my answer as the solution 🙂
If you found any information I've provided helpful, please give a Thumbs Up

If you have any questions, feel free to reach out or message me.
DutchDelight
Excursionist
30 0 6

Thank you! I haven't tried this out yet, but it makes sense. Thanks!

Cherb20
Shopify Partner
6 2 4

No worries, if my answer solved your issue I’d really appreciate if you could mark it as the solution. 

if not, let me know what happened and I’ll help troubleshoot. 

Cheers, have a good day!

If I answered your question, please Accept my answer as the solution 🙂
If you found any information I've provided helpful, please give a Thumbs Up

If you have any questions, feel free to reach out or message me.