App reviews, troubleshooting, and recommendations
Hello Is there any API exist to get product details like price by productID ?
Hi @masumluf ,
Hope you are doing well.
You can use the below mentioned API to fetch the product details using product id.
https://shopify.dev/api/admin-rest/2022-04/resources/product#get-products-product-id
Please mark it as a solution and leave a like if you find it helpful.
Cheers!!
Shubham
My api request will come from a store front , so I can not generate access token , i need to call another api to generate api token. so this method wont help me. but I found a solution in another way.
That is great!
Could you share that solution here as well so it will help others who might need it? 🙂
Use the below code to get the product information by product id
{% assign product_id = param | times: 1 %}
{% assign products_obj = collections.all.products | where: 'id', product_id %}
{% assign product = products_obj[0] %}
Where param is your product id. Let me know if that's work for you
This method is limited to 50 iterations, therefore it will only check for the 50 first products of the collection. In other words: it might not work.
I think you could still do:
{% paginate collections.all.products by 1000 %} {% assign product_id = param | times: 1 %}
{% assign products_obj = collections.all.products | where: 'id', product_id %}
{% assign product = products_obj[0] %} {% endpaginate %}
But this is a "trick" and if the collection starts to get too big this could make performances worst, so use with caution.
Yes please share the solution you found
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023