Products and variants: list and search with cursor pagination, fetch
one with variants, create, update, bulk-update variants and delete.
Needs read_products / write_products.
Values
PRODUCT_FIELDS
PRODUCT_FIELDS: Str "id title handle status vendor productType tags totalInventory createdAt updatedAt\npriceRangeV2 {\n minVariantPrice { amount currencyCode }\n maxVariantPrice { amount currencyCode }\n}"
VARIANT_FIELDS
VARIANT_FIELDS: Str "id title sku price compareAtPrice inventoryQuantity\nselectedOptions { name value }\ninventoryItem { id tracked }"
Functions
collect-products
fn (options: Map, max-items: Int): Vec
fn (options: Map, max-items: Int, opts: Map): Vec
Follow cursors and return up to max-items products (a Vec of nodes).
Options as in list-products.
Example
products ::shopify::products/collect-products({query: "status:active"}, 1000)
length(products)
create-product
fn (product: Map): Map
fn (product: Map, opts: Map): Map
Create a product (productCreate) from a ProductCreateInput:
title plus optional descriptionHtml, vendor, productType,
tags, status (ACTIVE, DRAFT, ARCHIVED), productOptions,
metafields, ... Shopify creates one default variant; set prices
and SKUs afterwards with update-variants.
Example
product ::shopify::products/create-product({title: "Cool socks", status: "DRAFT", tags: ["socks"]})
delete-product
fn (id: Str): Str
fn (id: Str, opts: Map): Str
Permanently delete a product and its variants (productDelete). Returns
the deleted product id. Prefer update-product with status: "ARCHIVED" when the product may be needed again.
Example
::shopify::products/delete-product("gid://shopify/Product/1")
get-product
fn (id: Str): Map?
fn (id: Str, opts: Map): Map?
One product by GraphQL id with its options and first 100 variants (price, SKU, inventory item id). Returns null when not found.
Example
product ::shopify::products/get-product("gid://shopify/Product/1")
product.title
list-products
fn (): Map
fn (options: Map): Map
fn (options: Map, opts: Map): Map
One page of products. Options: first (default 50, max 250),
after, query (e.g. "title:*sticker* status:active"), sortKey
(TITLE, CREATED_AT, UPDATED_AT, INVENTORY_TOTAL, ...),
reverse. Returns {nodes, pageInfo}.
Example
page ::shopify::products/list-products({first: 20, query: "status:active", sortKey: "UPDATED_AT", reverse: true})
map(page.nodes, %.title)
page.pageInfo.hasNextPage
search-products
fn (search-query: Str): Map
fn (search-query: Str, options: Map): Map
fn (search-query: Str, options: Map, opts: Map): Map
One page of products matching Shopify's search syntax (e.g.
"title:*sticker* status:active"). Options as in list-products.
Example
page ::shopify::products/search-products("title:*sticker* status:active", {first: 10})
map(page.nodes, %.handle)
update-product
fn (product: Map): Map
fn (product: Map, opts: Map): Map
Update a product (productUpdate) from a ProductUpdateInput that
includes the product id and the fields to change.
Example
::shopify::products/update-product({id: "gid://shopify/Product/1", status: "ARCHIVED"})
update-variants
fn (product-id: Str, variants: Vec): Vec
fn (product-id: Str, variants: Vec, options: Map): Vec
fn (product-id: Str, variants: Vec, options: Map, opts: Map): Vec
Update several variants of one product (productVariantsBulkUpdate).
Each variant is a ProductVariantsBulkInput with id plus fields
such as price, compareAtPrice, inventoryItem: {sku, tracked},
optionValues. Option allowPartialUpdates lets valid variants
save when others fail. Returns the updated variants.
Example
::shopify::products/update-variants("gid://shopify/Product/1", [
{id: "gid://shopify/ProductVariant/11", price: "19.00", inventoryItem: {sku: "SOCK-RED-M"}}
])