Hi,
I am completely now to Shopify.
I found this object which gives me the product level details from PDP page. I need to know the category id
meta.product
{id: 6789400526909, gid: 'gid://shopify/Product/6789400526909', vendor: 'Etiquette', type: 'Mens Briefs', variants: Array(4)}
Please help
Thanks,
Amit
Hi there,
since you’re talking about pages, I suppose your’re looking for some Liquid reference.
you can use the product.collections Liquid object in order to retrieve all the collections in which the product is actually listed, then you can loop this object in order to get the collection.id
https://shopify.dev/api/liquid/objects/product#product-collections
{% for collection in product.collections %}
{{ collection.id}}
{% endfor %}
Hi @francesco_gs ,
I am actually trying to get the collection id / catagory id from the web app itself, using the console. Do you know how to get the id using the console, not using Liqud language.
For example I will go to https://myapp.myshopify.com/ and press F12 and go to the console and try to find the catagory id from console of the browser.
Regards,
Amit
Hi Amit,
if you want to display the category id into the dev console of the browser you can just output it mixing together some Javascript and Liquid, like this
so that you will have N rows for each collection in where the product is listed
Hi @francesco_gs ,
I believe to do so I need to write the code in Liquid page. But I have no access to that.
If you will see the screenshot, you will see that there is a meta object from which I get the product details except the catagory id. Similarly I want to find the catagory id? Does that make sense?
Cheers,
Amit
Hi @amitsahoo ,
unfortunately this info doesn’t seem to be listed into the js object accessible from the dev.