Methods
fetch(id) → {Promise|GraphModel}
Fetches a single product by ID on the shop.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | The id of the product to fetch. |
- Source:
Returns:
A promise resolving with a GraphModel
of the product.
- Type
- Promise | GraphModel
Example
client.product.fetch('Xk9lM2JkNzFmNzIQ4NTIY4ZDFi9DaGVja291dC9lM2JkN==').then((product) => {
// Do something with the product
});
fetchAll(pageSizeopt) → {Promise|Array.<GraphModel>}
Fetches all products on the shop.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pageSize |
Int |
<optional> |
The number of products to fetch per page |
- Source:
Returns:
A promise resolving with an array of GraphModel
s of the products.
- Type
- Promise | Array.<GraphModel>
Example
client.product.fetchAll().then((products) => {
// Do something with the products
});
fetchByHandle(handle) → {Promise|GraphModel}
Fetches a single product by handle on the shop.
Parameters:
Name | Type | Description |
---|---|---|
handle |
String | The handle of the product to fetch. |
- Source:
Returns:
A promise resolving with a GraphModel
of the product.
- Type
- Promise | GraphModel
Example
client.product.fetchByHandle('my-product').then((product) => {
// Do something with the product
});
fetchMultiple(ids) → {Promise|Array.<GraphModel>}
Fetches multiple products by ID on the shop.
Parameters:
Name | Type | Description |
---|---|---|
ids |
Array.<String> | The ids of the products to fetch |
- Source:
Returns:
A promise resolving with a GraphModel
of the product.
- Type
- Promise | Array.<GraphModel>
Example
const ids = ['Xk9lM2JkNzFmNzIQ4NTIY4ZDFi9DaGVja291dC9lM2JkN==', 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ='];
client.product.fetchMultiple(ids).then((products) => {
// Do something with the products
});
fetchQuery(argsopt) → {Promise|Array.<GraphModel>}
Fetches all products on the shop that match the query.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
Object |
<optional> |
An object specifying the query data containing zero or more of: Properties
|
- Source:
Returns:
A promise resolving with an array of GraphModel
s of the products.
- Type
- Promise | Array.<GraphModel>
Example
client.product.fetchQuery({first: 20, sortKey: 'CREATED_AT', reverse: true}).then((products) => {
// Do something with the first 10 products sorted by title in ascending order
});
fetchRecommendations(productId) → {Promise|Array.<GraphModel>}
Find recommended products related to a given productId. To learn more about how recommendations are generated, see https://shopify.dev/themes/product-merchandising/recommendations.
Parameters:
Name | Type | Description |
---|---|---|
productId |
String | The id of the product to fetch. |
- Source:
Returns:
A promise resolving with an array of GraphModel
s of the products.
- Type
- Promise | Array.<GraphModel>
Example
const productId 'Xk9lM2JkNzFmNzIQ4NTIY4ZDFi9DaGVja291dC9lM2JkN==';
client.product.fetchProductRecommendations(productId).then((products) => {
// Do something with the products
});