Anchor to product
product
query
Returns a Product resource by ID.
Anchor to Possible returnsPossible returns
- Anchor to ProductProduct•
The
Product
object lets you manage products in a merchant’s store.Products are the goods and services that merchants offer to customers. They can include various details such as title, description, price, images, and options such as size or color. You can use product variants to create or update different versions of the same product. You can also add or update product media. Products can be organized by grouping them into a collection.
Learn more about working with Shopify's product model, including limitations and considerations.
Was this section helpful?
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
{
variables: {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
},
},
);
const data = await response.json();
query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) { product(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }",
"variables": {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
{
variables: {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
},
},
);
const data = await response.json();
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}
QUERY
variables = {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
}
response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
"variables": {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
},
},
});
Input variables
JSON{
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
}
Response
JSON{
"product": {
"linerMaterial": {
"value": "synthetic leather"
}
}
}