Skip to main content
ProductService fetches products and product metafields. Use it when your extension needs product data that the current context does not already provide.

Global name

API

Product

Methods

getProductByID

Fetches a product by ID.
Returns null when the product is not found.

getProductByHandle

Fetches a product by handle.
Returns null when the product is not found.

getProductMetaFields

Fetches product metafields. Pass metafield keys in namespace.key format.
The result is grouped by namespace, then by key. For example, ["custom.material", "custom.care"] returns { custom: { material, care } }. Keys that are not in namespace.key format, or that the product does not define, are left out.
MetaFieldDetails is a deprecated alias of MetaFieldsByNamespace.

getProductVariantStoreAvailability

Fetches the store availability of a product variant. Each result has the store, whether the variant is available there, and the optional quantityAvailable.

Metafield values

The metafield’s Shopify type decides the value type:
  • Decimal numbers are number, and integers are bigint. Values that do not parse stay as string.
  • Dates are Date.
  • Text, color, URL, rich text, JSON, money, weight, volume, dimension, and rating values are string.
  • A file reference is its URL as a string; a list of file references is MetaFieldMedia[].
  • Metaobject references are MetaObject, or MetaObject[] for lists.
MetafieldValue is a deprecated alias of MetaFieldValue. See @napps/component-extension models for MetaFieldMedia and MetaObject.

Reading product metafields

product.metaFields is a read-only accessor for values available on the product. It also accepts an array of namespace.key strings and returns a synchronous result grouped by namespace. Use product.getMetaFields(keys) when the values must be fetched; the resolved values are then available through the accessor.