If you don’t provide partial fields selection Tento will return all possible fields for Product
Tento Product Query
List
Tento represents Shopify Products query
IMPORTANT
const result = await client.products.list();
await client.products.list({
first: 10,
query: {
tag: "tento",
},
});
await client.products.list({
fields: {
id: true,
title: true,
metafields: true,
},
});
// result type
const result: {
items: {
id: string;
createdAt: Date;
updatedAt: Date;
isGiftCard: boolean;
category?: {
fullName: string;
id: string;
isLeaf: boolean;
isRoot: boolean;
name: string;
ancestorIds: number[];
childrenIds: number[];
isArchived: boolean;
level: number;
parentId?: number | undefined;
} | undefined;
... 30 more ...;
vendor: string;
}[];
pageInfo: {
startCursor: string;
endCursor: string;
hasNextPage: boolean;
hasPreviousPage: boolean;
};
}
Partial fields select
fields
parameter lets you include or omit fields you want to get from Shopify, Tento performs partial selects on the query level,
no additional data is transferred from the Shopify.
Include
Exclude
Both
const result = await client.products.list({
fields: {
id: true,
title: true,
},
});
Filters
Tento supports all pecific filters what Shopify has, see here.
Especially for products querying Tento supports all Shopify Products Query filters.
eq
not
gt
gte
lt
lte
raw
and
or
const result = await client.products.list({
query: {
id: "1"
},
});
Supported fields
All supported fields that can be used in filters:
const result = await client.products.list({
query: {
id: "1",
default: "product",
barcode: "ABC-abc-1234",
bundles: true, // false
categoryId: "gid://shopify/TaxonomyCategory/1",
combinedListingRole: "PARENT", // CHILD
createdAt: "2024-01-01",
deliveryProfileId: "1",
giftCard: true, // false
handle: "product-handle",
hasOnlyComposites: true, // false
hasOnlyDefaultVariant: true, // false
hasVariantWithComponents: true, // false
inventoryTotal: 1,
isPriceReduced: true, // false
outOfStockSomewhere: true, // false
price: 1,
productConfigurationOwner: "product owner",
productType: "product type",
publishedStatus: "HIDDEN", // 'ONLINE_STORE_CHANNEL', 'PUBLISHED', 'UNPUBLISHED', 'VISIBLE', 'UNAVAILABLE', 'HIDDEN', 'INTENDED', 'VISIBLE'
publishedAt: "2024-01-01",
sku: "XYZ-12345",
status: "ACTIVE", // 'ARCHIVED', 'DRAFT'
tag: "my_tag",
tagNot: "my_tag",
title: "Product Title",
updatedAt: "2024-01-01",
vendor: "Product Vendor",
},
});
Pagination
Tento supports Shopify pagination
first
Supported pagination options
option | default | description |
---|---|---|
first | 50 | requested number of nodes for each page. |
after | - | cursor to retrieve nodes after in the connection. |
const result = await client.products.list({
first: 10,
after: "In0="
});
last
Supported pagination options
option | default | description |
---|---|---|
last | - | requested number of nodes for each page. |
before | - | cursor to retrieve nodes after in the connection. |
IMPORTANT
To provide last
option you must specify before
cursor to prevent exceptions.
const result = await client.products.list({
last: 10,
before: "In0="
});
Sort
Tento supports Shopify Products query sort keys Supported sort keys
keys | id , created_at , inventory_total , product_type , published_at , relevance , title ,updated_at , vendor |
reverse | true , false (false as default) |
const result = await client.products.list({
sortKey: "id",
reverse: true,
});