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.null when the product is not found.
getProductByHandle
Fetches a product by handle.null when the product is not found.
getProductMetaFields
Fetches product metafields. Pass metafield keys innamespace.key format.
["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 thestore, 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 arebigint. Values that do not parse stay asstring. - 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 isMetaFieldMedia[]. - Metaobject references are
MetaObject, orMetaObject[]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.