Returns a Product resource by ID.


Anchor to id
id
required

The ID of the Product to return.


Was this section helpful?

Anchor to Product
Product
Access requirements

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

Hide code
DescriptionCopy
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/unstable/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"
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$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]);
Hide code
Input variables
Copy
{
  "namespace": "my_fields",
  "key": "liner_material",
  "ownerId": "gid://shopify/Product/108828309"
}
Hide code
Response
JSON
{
  "product": {
    "linerMaterial": {
      "value": "synthetic leather"
    }
  }
}